Compare commits

..

87 Commits

Author SHA1 Message Date
bootstraponline df75d2d60c Release 2.4.0 2012-11-11 15:08:45 -07:00
bootstraponline 2713aabeaf Update gemspec 2012-11-11 15:08:21 -07:00
bootstraponline 796d1b44c2 Update README.md 2012-11-11 14:46:58 -07:00
bootstraponline 470a7b8f52 Fix #579 2012-11-11 14:40:47 -07:00
bootstraponline f699b82a9f Fix #539 2012-11-11 14:18:14 -07:00
bootstraponline 44edb8c7da Merge pull request #576 from roman-zaharenkov/title_control
Page title control
2012-11-11 12:29:37 -08:00
bootstraponline bc4fc0edd9 Fix gitcode test 2012-11-11 13:14:25 -07:00
Roman Zaharenkov 6545fa691b Adjust page header / title generation.
Now page header can be generated by first h1 header from page content. But page title generated by URL is it was before.
2012-11-11 13:22:10 +03:00
Roman Zaharenkov 4954553927 Page title control
Allow to set page title by setting header inside page body. It will use header as title If header is present and page URL otherwise.
2012-11-11 13:20:14 +03:00
bootstraponline 9c50ba9eeb XSLT was never used 2012-11-10 17:02:27 -07:00
bootstraponline 9a67da145a Merge pull request #578 from github/fileview-hover-fix
Fileview hover fix
2012-11-10 15:59:28 -08:00
bootstraponline ca7d82278c Pretty print with nokogiri 2012-11-10 16:34:37 -07:00
bootstraponline f6245c53dd Add .gitattributes 2012-11-10 12:15:20 -07:00
bootstraponline 6888420cc6 Update file_view output 2012-11-10 12:15:19 -07:00
Daniel Kimsey c5631f5b7d Fixed a:hover not highlighting the a block correctly 2012-11-10 12:15:19 -07:00
Daniel Kimsey 34e0b49d72 Refactored the template generator to use new_page method 2012-11-10 12:15:19 -07:00
Daniel Kimsey bd072264ef Line-ending fix for _styles.css 2012-11-10 12:15:19 -07:00
bootstraponline cfb2d24c71 Merge pull request #577 from dekimsey/fix-page-metadata
Renamed page.meta_data => page.metadata
2012-11-09 18:03:12 -08:00
Daniel Kimsey fe0eb72fa3 Renamed page.meta_data to page.metadata for consistency with views 2012-11-09 18:29:49 -05:00
Daniel Kimsey 2783257f06 Added page.meta_data to tests 2012-11-09 18:25:33 -05:00
bootstraponline cc11cb866c Add css note
#572
2012-11-08 18:51:57 -07:00
bootstraponline 6a02643bda Merge pull request #573 from dekimsey/license-guidelines
Added bootstraponline's comment about licensing guidelines
2012-11-08 16:12:40 -08:00
Daniel Kimsey 7f269c8da3 Added bootstraponline's comment about licensing guidelines 2012-11-08 16:46:49 -05:00
bootstraponline ef7f7cebd1 Release 2.3.12 2012-11-07 20:37:50 -07:00
bootstraponline 05c24fd5e3 Fix #570
Fix #571
2012-11-07 20:35:57 -07:00
bootstraponline b08b97bd28 Release 2.3.11 2012-11-07 20:18:43 -07:00
bootstraponline dbb6ce2f71 Fix #570
Error in gollum.js broke new page button.
2012-11-07 20:17:50 -07:00
bootstraponline f66f14b593 Release 2.3.10 2012-11-07 19:47:09 -07:00
bootstraponline 8a52315dee Add base url to custom css 2012-11-07 19:46:27 -07:00
bootstraponline 7c4052906c Add custom css 2012-11-07 19:40:52 -07:00
bootstraponline 3a56f39f6a Fix readme 2012-11-07 19:17:49 -07:00
bootstraponline 6585ca5dd0 Fix space 2012-11-07 19:13:57 -07:00
bootstraponline 792abae07e Release 2.3.9 2012-11-07 19:11:04 -07:00
bootstraponline 74ce648c59 Options.fetch 2012-11-07 19:04:36 -07:00
bootstraponline 2686e96046 Release 2.3.8 2012-11-07 18:50:37 -07:00
bootstraponline 213e2bb432 Add config example 2012-11-07 18:48:07 -07:00
bootstraponline 79bb5c10ab Remove lib.so note 2012-11-07 18:46:36 -07:00
bootstraponline 7ea012d786 Fix code style 2012-11-07 18:45:20 -07:00
bootstraponline 43591f75de Merge pull request #570 from dekimsey/only-alert-on-changes
Only alert on changes
2012-11-07 17:39:30 -08:00
Daniel Kimsey 05d82c0569 Attach unsaved changes warning to trigger only after changes are made 2012-11-07 17:51:36 -05:00
Daniel Kimsey 76c8d3206c Consolidated create and edit page's javascript into the global gollum.js 2012-11-07 17:50:12 -05:00
bootstraponline 00751d05b4 Release 2.3.7 2012-11-06 18:27:05 -07:00
bootstraponline b5be5df11a Fix test name 2012-11-06 18:26:49 -07:00
bootstraponline 7d159273fc Merge pull request #569 from dekimsey/issue-568
Fixed #568, triple tilde without language causes Gollum to crash
2012-11-06 17:11:08 -08:00
Daniel Kimsey 70127922ab Added test for #568 2012-11-06 15:49:47 -05:00
Daniel Kimsey b95df93775 Fixes #568, triple-tilde without language causes crash 2012-11-06 15:39:39 -05:00
bootstraponline dc06edcf5b Add x.y.z 2012-11-05 17:30:01 -07:00
bootstraponline fdc437dcd5 Release 2.3.6 2012-11-05 17:28:51 -07:00
bootstraponline f6873c9612 Merge pull request #566 from dekimsey/deterministic-search
Gollum search results now displayed in a deterministic order
2012-11-05 16:17:40 -08:00
Daniel Kimsey 93754ab32d Sort by filename in addition to count 2012-11-05 18:01:50 -05:00
Daniel Kimsey 5759334635 Gollum search results are displayed in a deterministic order 2012-11-05 17:02:19 -05:00
bootstraponline f2f543b72d Release 2.3.5 2012-10-31 20:14:15 -06:00
bootstraponline 598b052be3 Fix clean
Duplicate slashes must be removed everywhere.
2012-10-31 20:11:23 -06:00
bootstraponline a746062422 Merge pull request #564 from nikitug/patch-1
Update README to new Sequence diagram markup style
2012-10-31 19:09:45 -07:00
Nikita Afanasenko c8868d369f Update README to new Sequence diagram markup style 2012-10-31 18:02:28 +04:00
bootstraponline 52c6e7474c Release 2.3.4 2012-10-28 20:59:06 -06:00
bootstraponline be81f09b0e Update gemspec 2012-10-28 12:43:51 -06:00
bootstraponline 6fa4504e31 Fix #551 2012-10-28 12:37:02 -06:00
bootstraponline 992ba01a12 Fix page file dir 2012-10-28 11:57:25 -06:00
bootstraponline 72c5a74cf1 Update test
The test passes when verified manually using bin/gollum. Without a running server the test
will fail so it has been commented out. If there's an easy way to mock Rack::Server
then the test can be restored.
2012-10-27 23:44:11 -06:00
bootstraponline 919f41a0f1 Fix #559 2012-10-27 23:44:11 -06:00
bootstraponline 785921cb0f Fix toc generation 2012-10-27 21:46:30 -06:00
bootstraponline 8c8cda5e7d Fix comment 2012-10-27 21:05:56 -06:00
bootstraponline 64ef74e7e9 Add preview button to live preview 2012-10-27 20:52:54 -06:00
bootstraponline 776df4e6ee Fix nokogiri rendering
https://github.com/sparklemotion/nokogiri/issues/782
2012-10-27 19:52:26 -06:00
bootstraponline 68465a8651 Set indent and encoding 2012-10-27 18:12:32 -06:00
bootstraponline fa16c8960c Fix #560 2012-10-27 17:58:14 -06:00
bootstraponline 2c57915781 Refactor fileview 2012-10-23 23:27:31 -06:00
bootstraponline d0527f1aeb Release 2.3.3 2012-10-23 22:58:41 -06:00
bootstraponline 75083c5b56 Fix collapse tree 2012-10-23 22:36:17 -06:00
bootstraponline 82526594db Add attr reader for collapse tree 2012-10-23 22:22:56 -06:00
bootstraponline 941d39800c Merge pull request #556 from adiknoth/fileview
Documentation and usability enhancement of recent fileview fix
2012-10-23 21:20:28 -07:00
bootstraponline a1ae2e8bc0 Fix #554 2012-10-23 22:14:45 -06:00
bootstraponline 4af6f366ca Fix show_all /pages 2012-10-23 22:09:27 -06:00
Adrian Knoth c7a9534ed9 Add --collapse-tree command line option 2012-10-23 14:27:15 +02:00
Adrian Knoth 00bcbbf72b File View: Add option to collapse file trees.
For potentially large repositories, starting with a collapsed tree may
be beneficial.
2012-10-23 14:27:12 +02:00
Adrian Knoth ed2254ff9f Add missing documentation for --show-all 2012-10-23 14:22:54 +02:00
bootstraponline b6633f0ecb Release 2.3.2 2012-10-22 19:21:10 -06:00
bootstraponline e08d2d3052 Enable show_all for /pages 2012-10-22 19:10:40 -06:00
bootstraponline fbc0548b43 Add --show-all
--show-all will show all files in file view (not just valid pages). Default is false.
2012-10-22 19:03:21 -06:00
bootstraponline a9807bd1e1 Update math note 2012-10-21 17:22:31 -06:00
bootstraponline 554b80b39d Add MathJax examples 2012-10-21 17:21:24 -06:00
bootstraponline 99e74bf00b Release 2.3.1 2012-10-21 17:16:40 -06:00
bootstraponline f48e923f28 Fix release 2012-10-21 17:15:09 -06:00
bootstraponline 5400b4bfdd Support inline and display math.
$$2^2$$

$2^2$

\\(2^2\\)

[2^2]
2012-10-21 17:15:09 -06:00
bootstraponline f68bebe0f6 Update math note 2012-10-21 16:26:35 -06:00
bootstraponline 4c6019b439 Update math note 2012-10-21 16:23:58 -06:00
54 changed files with 739 additions and 306 deletions
+25
View File
@@ -0,0 +1,25 @@
# https://help.github.com/articles/dealing-with-line-endings
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto
# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.txt text
*.md text
*.rb text
*.js text
*.html text
*.yml text
*.mustache text
*.css text
Rakefile text
Gemfile text
LICENSE text
COPYRIGHT text
gollum text
.gitattributes text
.gitignore text
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
+27 -19
View File
@@ -136,7 +136,13 @@ or JavaScript. These tags will be stripped from the converted HTML. See
`docs/sanitization.md` for more details on what tags and attributes are
allowed.
## TITLES
The first defined `h1` will override the default header on a page. There are two ways to set a page title. The metadata syntax:
`<!-- --- title: New Title -->`
The first `h1` tag can be set to always override the page title, without needing to use the metadata syntax. Start gollum with the `--h1-title` flag.
## BRACKET TAGS
A variety of Gollum tags use a double bracket syntax. For example:
@@ -363,25 +369,17 @@ appropriately.
## MATHEMATICAL EQUATIONS
Start gollum with the `--mathjax` flag. Read more about [MathJax](http://docs.mathjax.org/en/latest/index.html) on the web. Gollum uses the `TeX-AMS-MML_HTMLorMML` config with the `autoload-all` extension.
Page files may contain mathematic equations in TeX syntax that will be nicely
typeset into the expected output. A block-style equation is delimited by `\[`
and `\]`. For example:
Inline math:
\[ P(E) = {n \choose k} p^k (1-p)^{ n-k} \]
- $2^2$
- `\\(2^2\\)`
Inline equations are delimited by `\(` and `\)`. These equations will appear
inline with regular text. For example:
Display math:
The Pythagorean theorem is \( a^2 + b^2 = c^2 \).
### INSTALLATION REQUIREMENTS
In order to get the mathematical equations rendering to work, you need the following binaries:
* LaTex, TeTex or MacTex/BasicTeX (pdflatex)
* Netpbm (pnmcrop, pnmpad, pnmscale, ppmtopgm, pnmgamma, pnmtopng)
* Ghostscript (gs)
- $$2^2$$
- [2^2]
## SEQUENCE DIAGRAMS
@@ -389,10 +387,10 @@ You may imbed sequence diagrams into your wiki page (rendered by
[WebSequenceDiagrams](http://www.websequencediagrams.com) by using the
following syntax:
{{{ blue-modern
{{{{{{ blue-modern
alice->bob: Test
bob->alice: Test response
}}}
}}}}}}
You can replace the string "blue-modern" with any supported style.
@@ -540,9 +538,17 @@ Your Rack middleware can pass author details to Gollum in a Hash in the session
## WINDOWS FILENAME VALIDATION
Note that filenames on windows must not contain any of the following characters `\ / : * ? " < > |`. See [this support article](http://support.microsoft.com/kb/177506) for details.
## LIB.SO ERROR
## CONFIG FILE
`Could not open library 'lib.so'` may be solved by installing `python-devel` on Fedora or `python-dev` on Ubuntu. Gentoo requires a rubypython [patch](https://gist.github.com/2802480) to use python2.7.
Gollum optionally takes a `--config file`. See [config.rb](https://github.com/github/gollum/blob/master/config.rb) for an example.
## CUSTOM CSS
The `--css` flag will inject `custom.css` from the root of your git repository into each page. `custom.css` must be commited to git or you will get a 302 redirect to the create page. Here's an example of floating the sidebar to the left.
```css
#wiki-rightbar { float: left !important; }
```
## CONTRIBUTE
@@ -564,6 +570,8 @@ your changes merged back into core is as follows:
1. Send a pull request to the github/gollum project.
## RELEASING
x.y.z
For z releases:
$ rake bump
$ rake release
+2 -1
View File
@@ -114,6 +114,7 @@ task :release => :build do
exit!
end
sh "git commit --allow-empty -a -m 'Release #{version}'"
sh "git pull"
sh "git tag v#{version}"
sh "git push origin master"
sh "git push origin v#{version}"
@@ -145,7 +146,7 @@ task :gemspec => :validate do
split("\n").
sort.
reject { |file| file =~ /^\./ }.
reject { |file| file =~ /^(rdoc|pkg|test|Home\.md)/ }.
reject { |file| file =~ /^(rdoc|pkg|test|Home\.md|\.gitattributes)/ }.
map { |file| " #{file}" }.
join("\n")
+15
View File
@@ -45,6 +45,10 @@ opts = OptionParser.new do |opts|
options['irb'] = true
end
opts.on("--css", "Inject custom css. Uses custom.css from root repository") do
wiki_options[:css] = true
end
opts.on("--page-file-dir [PATH]", "Specify the sub directory for all page files (default: repository root).") do |path|
wiki_options[:page_file_dir] = path
end
@@ -68,6 +72,17 @@ 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
opts.on("--h1-title", "Sets page title to value of first h1") do
wiki_options[:h1_title] = true
end
end
# Read command line options into `options` hash
+28
View File
@@ -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
View File
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
s.required_ruby_version = ">= 1.8.7"
s.name = 'gollum'
s.version = '2.3.0'
s.date = '2012-10-21'
s.version = '2.4.0'
s.date = '2012-11-11'
s.rubyforge_project = 'gollum'
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('wikicloth', '~> 0.8.0')
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 =
s.files = %w[
@@ -50,6 +53,7 @@ Gem::Specification.new do |s|
README.md
Rakefile
bin/gollum
config.rb
docs/sanitization.md
gollum.gemspec
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/livepreview/css/custom.css
lib/gollum/frontend/public/gollum/livepreview/images/cancel_24.png
lib/gollum/frontend/public/gollum/livepreview/images/globe_24.png
lib/gollum/frontend/public/gollum/livepreview/images/lr_24.png
lib/gollum/frontend/public/gollum/livepreview/images/save_24.png
lib/gollum/frontend/public/gollum/livepreview/images/savecomment_24.png
+2 -1
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
# stdlib
require 'digest/md5'
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__)
module Gollum
VERSION = '2.3.0'
VERSION = '2.4.0'
def self.assets_path
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
+1
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
module Gollum
class BlobEntry
# Gets the String SHA for this blob.
+1
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
module Gollum
# Responsible for handling the commit process for a Wiki. It sets up the
# Git index, provides methods for modifying the tree, and stores callbacks
+17
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
module Gollum
class File
Wiki.file_class = self
@@ -13,6 +14,22 @@ module Gollum
@path = nil
end
# Public: The url path required to reach this page within the repo.
#
# Returns the String url_path
def url_path
path = self.path
path = path.sub(/\/[^\/]+$/, '/') if path.include?('/')
path
end
# Public: The url_path, but CGI escaped.
#
# Returns the String url_path
def escaped_url_path
CGI.escape(self.url_path).gsub('%2F','/')
end
# Public: The on-disk filename of the file.
#
# Returns the String name.
+22 -12
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
module Gollum
=begin
FileView requires that:
@@ -5,8 +6,13 @@ module Gollum
- Then all the folders are sorted and processed
=end
class FileView
def initialize pages
# common use cases:
# set pages to wiki.pages and show_all to false
# set pages to wiki.pages + wiki.files and show_all to true
def initialize pages, options = {}
@pages = pages
@show_all = options[:show_all] || false
@checked = options[:collapse_tree] ? '' : "checked"
end
def enclose_tree string
@@ -16,7 +22,7 @@ module Gollum
def new_page page
name = page.name
url = url_for_page page
%Q( <li class="file"><a href="#{url}">#{name}</a></li>\n)
%Q( <li class="file"><a href="#{url}"><span class="icon"></span>#{name}</a></li>)
end
def new_folder folder_path
@@ -26,20 +32,26 @@ module Gollum
def new_sub_folder path
<<-HTML
<li>
<label>#{path}</label> <input type="checkbox" checked />
<label>#{path}</label> <input type="checkbox" #{@checked} />
<ol>
HTML
end
def end_folder
<<-HTML
</ol>
</li>
HTML
"</ol></li>\n"
end
def url_for_page page
url = ::File.join(::File.dirname(page.path), page.filename_stripped)
url = ''
if @show_all
# Remove ext for valid pages.
filename = page.filename
filename = Page::valid_page_name?(filename) ? filename.chomp(::File.extname(filename)) : filename
url = ::File.join(::File.dirname(page.path), filename)
else
url = ::File.join(::File.dirname(page.path), page.filename_stripped)
end
url = url[2..-1] if url[0,2] == './'
url
end
@@ -70,13 +82,11 @@ module Gollum
# Handle special case of only one folder.
if (count - folder_start == 1)
page = @pages[ folder_start ]
name = page.name
url = url_for_page page
html += <<-HTML
<li>
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" checked />
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" #{@checked} />
<ol>
<li class="file"><a href="#{url}">#{name}</a></li>
#{new_page page}
</ol>
</li>
HTML
+29 -17
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
require 'cgi'
require 'sinatra'
require 'gollum'
@@ -82,11 +83,12 @@ module Precious
before do
@base_url = url('/', false).chomp('/')
settings.wiki_options.merge!({ :base_path => @base_url }) unless settings.wiki_options.has_key? :base_path
# above will detect base_path when it's used with map in a config.ru
settings.wiki_options.merge!({ :base_path => @base_url })
end
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
# path is set to name if path is nil.
@@ -187,24 +189,20 @@ module Precious
post '/create' do
name = params[:page].to_url
path = sanitize_empty_params(params[:path])
path = '' if path.nil?
path = sanitize_empty_params(params[:path]) || ''
format = params[:format].intern
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)
# ensure pages are created in page_file_dir
page_dir = settings.wiki_options[:page_file_dir].to_s
path = clean_url(::File.join(page_dir, path)) unless path.start_with?(page_dir)
# 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)
begin
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
@message = "Duplicate page: #{e.message}"
mustache :error
@@ -240,6 +238,8 @@ module Precious
@content = @page.formatted_data
@toc_content = wiki.universal_toc ? @page.toc_data : nil
@mathjax = wiki.mathjax
@css = wiki.css
@h1_title = wiki.h1_title
@editable = false
mustache :page
end
@@ -308,7 +308,8 @@ module Precious
get '/search' do
@query = params[:q]
wiki = wiki_new
@results = wiki.search @query
# Sort wiki search results by count (desc) and then by name (asc)
@results = wiki.search(@query).sort{ |a, b| (a[:count] <=> b[:count]).nonzero? || b[:name] <=> a[:name] }.reverse
@name = @query
mustache :search
end
@@ -323,13 +324,21 @@ module Precious
wiki_options = settings.wiki_options.merge({ :page_file_dir => @path })
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
@results = wiki.pages
@results += wiki.files if settings.wiki_options[:show_all]
@ref = wiki.ref
mustache :pages
end
get '/fileview' do
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
@results = Gollum::FileView.new(wiki.pages).render_files
wiki = wiki_new
options = settings.wiki_options
content = wiki.pages
# if showing all files include wiki.files
content += wiki.files if options[:show_all]
# must pass wiki_options to FileView
# --show-all and --collapse-tree can be set.
@results = Gollum::FileView.new(content, options).render_files
@ref = wiki.ref
mustache :file_view, { :layout => false }
end
@@ -340,10 +349,11 @@ module Precious
def show_page_or_file(fullpath)
name = extract_name(fullpath)
path = extract_path(fullpath)
path = extract_path(fullpath) || '/'
wiki = wiki_new
path = '/' if path.nil?
page_dir = settings.wiki_options[:page_file_dir].to_s
path = ::File.join(page_dir, path) unless path.start_with?(page_dir)
if page = wiki.paged(name, path, exact = true)
@page = page
@@ -352,6 +362,8 @@ module Precious
@content = page.formatted_data
@toc_content = wiki.universal_toc ? @page.toc_data : nil
@mathjax = wiki.mathjax
@css = wiki.css
@h1_title = wiki.h1_title
mustache :page
elsif file = wiki.file(fullpath)
content_type file.mime_type
+3 -1
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
module Precious
module Helpers
# Extract the path string that Gollum::Wiki expects
@@ -19,9 +20,10 @@ module Precious
end
# Remove all slashes from the start of string.
# Remove all double slashes
def clean_url url
return url if url.nil?
url.gsub('%2F','/').gsub(/^\/+/,'')
url.gsub('%2F','/').gsub(/^\/+/,'').gsub('//','/')
end
def trim_leading_slash url
+128 -121
View File
@@ -1,121 +1,128 @@
*, html {
font-family: Verdana, Arial, Helvetica, sans-serif;
}
#results a:hover {
background-color: #4c4c4c;
}
#home_button {
position: absolute;
top: 10px;
left: 50%;
}
#home_button .minibutton {
font-size: 1em;
text-align: center;
}
#results {
position: absolute;
top: 60px;
left: 10px;
}
body, form, ul, li, p, h1, h2, h3, h4, h5 {
margin: 0;
padding: 0;
}
body {
background-color: #606061;
color: #ffffff;
margin: 0;
}
img {
border: none;
}
p {
font-size: 1em;
margin: 0 0 1em 0;
}
html { font-size: 100%; /* IE hack */ }
body { font-size: 1em; /* Sets base font size to 16px */ }
table { font-size: 100%; /* IE hack */ }
input, select, textarea, th, td { font-size: 1em; }
/* Prevent wrapping on large file names. */
li.file {
white-space: nowrap;
}
/* CSS Tree menu styles */
ol.tree
{
padding: 0 0 0 30px;
width: 300px;
}
li
{
position: relative;
margin-left: -15px;
list-style: none;
}
li.file
{
margin-left: -1px !important;
height: 1.5em;
}
li.file a
{
background: url(../images/fileview/document.png) 0 0 no-repeat;
color: #fff;
padding-left: 21px;
text-decoration: none;
display: block;
}
li.file a[href *= '.pdf'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href *= '.html'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href $= '.css'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href $= '.js'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li input
{
position: absolute;
left: 0;
margin-left: 0;
opacity: 0;
z-index: 2;
cursor: pointer;
height: 1em;
width: 1em;
top: 0;
}
li input + ol
{
background: url(../images/fileview/toggle-small-expand.png) 40px 0 no-repeat;
margin: -1.188em 0 0 -44px; /* 15px */
height: 1.5em;
}
li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; }
li label
{
background: url(../images/fileview/folder-horizontal.png) 15px 1px no-repeat;
cursor: pointer;
display: block;
padding-left: 37px;
}
li input:checked + ol
{
background: url(../images/fileview/toggle-small.png) 40px 5px no-repeat;
margin: -1.5em 0 0 -44px; /* 20px */
padding: 1.563em 0 0 80px;
height: auto;
}
li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */}
li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ }
*, html {
font-family: Verdana, Arial, Helvetica, sans-serif;
}
#results a:hover {
background-color: #4c4c4c;
}
#home_button {
position: absolute;
top: 10px;
left: 50%;
}
#home_button .minibutton {
font-size: 1em;
text-align: center;
}
#results {
position: absolute;
top: 60px;
left: 10px;
}
body, form, ul, li, p, h1, h2, h3, h4, h5 {
margin: 0;
padding: 0;
}
body {
background-color: #606061;
color: #ffffff;
margin: 0;
}
img {
border: none;
}
p {
font-size: 1em;
margin: 0 0 1em 0;
}
html { font-size: 100%; /* IE hack */ }
body { font-size: 1em; /* Sets base font size to 16px */ }
table { font-size: 100%; /* IE hack */ }
input, select, textarea, th, td { font-size: 1em; }
/* Prevent wrapping on large file names. */
li.file {
white-space: nowrap;
}
/* CSS Tree menu styles */
ol.tree
{
padding: 0 0 0 30px;
width: 300px;
}
li
{
position: relative;
margin-left: -15px;
list-style: none;
}
li.file
{
margin-left: -1px !important;
height: 1.5em;
}
li.file a
{
color: #fff;
text-decoration: none;
display: inline-block;
}
li.file a span.icon
{
width: 14px;
height: 18px;
background: url(../images/fileview/document.png) 0 0 no-repeat;
display: inline-block;
margin-right: 7px;
vertical-align: text-top;
}
li.file a[href *= '.pdf'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href *= '.html'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href $= '.css'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href $= '.js'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li input
{
position: absolute;
left: 0;
margin-left: 0;
opacity: 0;
z-index: 2;
cursor: pointer;
height: 1em;
width: 1em;
top: 0;
}
li input + ol
{
background: url(../images/fileview/toggle-small-expand.png) 40px 0 no-repeat;
margin: -1.188em 0 0 -44px; /* 15px */
height: 1.5em;
}
li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; }
li label
{
background: url(../images/fileview/folder-horizontal.png) 15px 1px no-repeat;
cursor: pointer;
display: block;
padding-left: 37px;
}
li input:checked + ol
{
background: url(../images/fileview/toggle-small.png) 40px 5px no-repeat;
margin: -1.5em 0 0 -44px; /* 20px */
padding: 1.563em 0 0 80px;
height: auto;
}
li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */}
li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ }
@@ -212,4 +212,20 @@ $(document).ready(function() {
$('#gollum-revert-form').submit();
});
}
if( $('#wiki-wrapper.edit').length ){
$("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } );
$("#gollum-editor-body").one('change', function(){
window.onbeforeunload = function(){ return "Leaving will discard all edits!" };
});
$.GollumEditor();
}
if( $('#wiki-wrapper.create').length ){
$("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } );
$("#gollum-editor-body").one('change', function(){
window.onbeforeunload = function(){ return "Leaving will not create a new page!" };
});
$.GollumEditor({ NewFile: true, MarkupType: default_markup });
}
});
Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

@@ -11,6 +11,7 @@
<div id='previewframe'><div id='contentframe' class='markdown-body'></div></div>
<!-- tool panel from notepage.es. save & savecomment icons from Retina Display Icon Set. -->
<div id='toolpanel' class='toolpanel edit' style='width: 500px; right: 0px; visibility: hidden;'>
<a id='preview' class='edit'><img src='images/globe_24.png' alt='Preview' title='Preview'></a>
<a id='save' class='edit'><img src='images/save_24.png' alt='Save' title='Save'></a>
<a id='savecomment' class='edit'><img src='images/savecomment_24.png' alt='Save with comment' title='Save with comment'></a>
<a id='toggle' class='edit' href='javascript:void(0)' onclick='jsm.toggleLeftRight();'><img src='images/lr_24.png' alt='Toggle left to right' title='Toggle left to right'></a>
@@ -87,6 +87,18 @@ defaultCommitMessage = function() {
// Set comment using the default commit message.
commentEditorSession.setValue( defaultCommitMessage() );
$.preview = function( previewWindow ) {
jQuery.ajax( {
type: 'POST',
url: baseUrl + '/preview',
data: { page: 'Preview: ' + pageName, format: 'markdown', content: editorSession.getValue() },
success: function( html ) {
previewWindow.document.write( html );
previewWindow.focus();
}
});
}
$.save = function( commitMessage ) {
win.onbeforeunload = null;
@@ -96,8 +108,9 @@ $.save = function( commitMessage ) {
var msg = defaultCommitMessage();
var newLocation = baseUrl;
// Remove all duplicate slashes
function clean( str ) {
return str.replace(/^\/+/, '/');
return str.replace(/\/+/g, '/');
}
// 'a%2Fb' => a/b
@@ -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();
return false;
});
// Hide dimmer, comment tool panel, and comment.
@@ -15,7 +15,10 @@ CC BY-SA 3.0 Unported
http://blog.twg.ca/2010/11/retina-display-icon-set/
http://creativecommons.org/licenses/by-sa/3.0/legalcode.txt
lib/gollum/frontend/public/images/savecomment_24.png
lib/gollum/frontend/public/images/cancel_24.png
lib/gollum/frontend/public/images/save_24.png
lib/gollum/frontend/public/images/globe_24.png
---
@@ -1,4 +1,4 @@
<div id="wiki-wrapper">
<div id="wiki-wrapper" class="create">
<div id="head">
<h1>Create New Page</h1>
</div>
@@ -9,12 +9,6 @@
</div>
</div>
<script type="text/javascript">
window.onbeforeunload = function(){ return "Leaving will not create a new page!" };
$("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } );
jQuery(document).ready(function() {
$.GollumEditor({ NewFile: true, MarkupType: '{{default_markup}}' });
});
var default_markup = '{{default_markup}}';
</script>
{{something}}
@@ -10,11 +10,3 @@
</div>
<div id="wiki-content">{{>editor}}</div>
</div>
<script type="text/javascript">
window.onbeforeunload = function(){ return "Leaving will discard all edits!" };
$("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } );
jQuery(document).ready(function() {
$.GollumEditor();
});
</script>
@@ -6,6 +6,7 @@
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/editor.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/dialog.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/template.css" media="all">
{{#css}}<link rel="stylesheet" type="text/css" href="{{base_url}}/custom.css" media="all">{{/css}}
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/ie7.css" media="all">
@@ -20,7 +21,13 @@
<script type="text/javascript" src="{{base_url}}/javascript/editor/gollum.editor.js"></script>
{{#mathjax}}
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ TeX: { extensions: ["autoload-all.js"] }});
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ['\\(','\\)']],
displayMath: [ ['$$','$$'], ['\[','\]'] ],
processEscapes: true
},
TeX: { extensions: ["autoload-all.js"] }});
</script>
<script>(function(d,j){
j = d.createElement('script');
+1 -1
View File
@@ -7,7 +7,7 @@ Mousetrap.bind(['e'], function( e ) {
</script>
<div id="wiki-wrapper" class="page">
<div id="head">
<h1>{{title}}</h1>
<h1>{{page_header}}</h1>
<ul class="actions">
<li class="minibutton">
{{>searchbar}}
+56 -1
View File
@@ -8,7 +8,16 @@ module Precious
DEFAULT_AUTHOR = 'you'
def title
@page.url_path.gsub("-", " ")
h1 = @h1_title ? page_header_from_content(@content) : false
h1 || @page.url_path_title
end
def page_header
page_header_from_content(@content) || title
end
def content
content_without_page_header(@content)
end
def author
@@ -80,6 +89,10 @@ module Precious
@mathjax
end
def css # custom css
@css
end
# Access to embedded metadata.
#
# Examples
@@ -90,6 +103,48 @@ module Precious
def metadata
@page.metadata
end
private
# Wraps page formatted data to Nokogiri::HTML document.
#
def build_document(content)
Nokogiri::HTML(%{<div id="gollum-root">} + content + %{</div>})
end
# Finds header node inside Nokogiri::HTML document.
#
def find_header_node(doc)
case self.format
when :asciidoc
doc.css("div#gollum-root > div#header > h1:first-child")
when :org
doc.css("div#gollum-root > p.title:first-child")
when :pod
doc.css("div#gollum-root > a.dummyTopAnchor:first-child + h1")
when :rest
doc.css("div#gollum-root > div > div > h1:first-child")
else
doc.css("div#gollum-root > h1:first-child")
end
end
# Extracts title from page if present.
#
def page_header_from_content(content)
doc = build_document(content)
title = find_header_node(doc)
Sanitize.clean(title.to_html).strip unless title.empty?
end
# Returns page content without title if it was extracted.
#
def content_without_page_header(content)
doc = build_document(content)
title = find_header_node(doc)
title.remove unless title.empty?
doc.css("div#gollum-root").inner_html
end
end
end
end
+1
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
module Gollum
# Controls all access to the Git objects from Gollum. Extend this class to
# add custom caching for special cases.
+1
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
require 'net/http'
require 'net/https' # ruby 1.8.7 fix, remove at upgrade
require 'uri'
+16 -5
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
require 'digest/sha1'
require 'cgi'
require 'pygments'
@@ -37,6 +38,7 @@ module Gollum
@premap = {}
@toc = nil
@metadata = nil
@to_xml = { :save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML ^ 1, :indent => 0, :encoding => 'UTF-8' }
end
# Render the content with Gollum wiki syntax on top of the file's own
@@ -74,13 +76,18 @@ module Gollum
doc,toc = process_headers(doc)
@toc = @sub_page ? ( @parent_page ? @parent_page.toc_data : "[[_TOC_]]" ) : toc
yield doc if block_given?
data = doc.to_xhtml
# nokogiri's save options are ored together. FORMAT has a value of 1 so ^ 1 removes it.
# formatting will create extra spaces in pre tags.
# https://github.com/sparklemotion/nokogiri/issues/782
# DEFAULT_HTML encodes unicode so XHTML is used for proper unicode support in href.
data = doc.to_xml( @to_xml )
data = process_toc_tags(data)
data = process_wsd(data)
data.gsub!(/<p><\/p>/) do
''
end
data
end
@@ -119,7 +126,7 @@ module Gollum
node.add_child(%Q{<a href="##{h_name}">#{h.content}</a>})
tail.add_child(node)
end
toc = toc.to_xhtml if toc != nil
toc = toc.to_xml(@to_xml) if toc != nil
[doc, toc]
end
@@ -481,8 +488,10 @@ module Gollum
# extract lang from { .ruby } or { #stuff .ruby .indent }
# see http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks
lang = lang.match(/\.([^}\s]+)/)
lang = lang[1] unless lang.nil?
if lang
lang = lang.match(/\.([^}\s]+)/)
lang = lang[1] unless lang.nil?
end
@codemap[id] = cached ?
{ :output => cached } :
@@ -543,7 +552,9 @@ module Gollum
blocks.each do |lang, code|
encoding ||= 'utf-8'
begin
hl_code = Pygments.highlight(code, :lexer => lang, :options => {:encoding => encoding.to_s})
# must set startinline to true for php to be highlighted without <?
# http://pygments.org/docs/lexers/
hl_code = Pygments.highlight(code, :lexer => lang, :options => {:encoding => encoding.to_s, :startinline => true})
rescue
hl_code = code
end
+23 -1
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
module Gollum
class Page
include Pagination
@@ -167,6 +168,27 @@ module Gollum
path
end
# Public: Defines title for page.rb
#
# Returns the String title
def url_path_title
metadata_title || url_path.gsub("-", " ")
end
# Public: Metadata title
#
# Set with <!-- --- title: New Title --> in page content
#
# Returns the String title or nil if not defined
def metadata_title
if metadata
title = metadata['title']
return title unless title.nil?
end
nil
end
# Public: The url_path, but CGI escaped.
#
# Returns the String url_path
@@ -220,7 +242,7 @@ module Gollum
# Public: Embedded metadata.
#
# Returns Hash of metadata.
def meta_data()
def metadata()
formatted_data if markup_class.metadata == nil
markup_class.metadata
end
+2 -1
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
module Gollum
module Pagination
def self.included(klass)
@@ -58,4 +59,4 @@ module Gollum
self.class.log_pagination_options(options)
end
end
end
end
+1
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
module Gollum
# Encapsulate sanitization options.
#
+1
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
require 'net/http'
require 'uri'
require 'open-uri'
+46 -18
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
module Gollum
class Wiki
include Pagination
@@ -136,6 +137,14 @@ module Gollum
# Gets the boolean live preview value.
attr_reader :live_preview
# Injects custom css from custom.css in root repo.
# Defaults to false
attr_reader :css
# Sets page title to value of first h1
# Defaults to false
attr_reader :h1_title
# Public: Initialize a new Gollum Repo.
#
# path - The String path to the Git repository that holds the Gollum
@@ -154,6 +163,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 = {})
@@ -162,24 +174,33 @@ module Gollum
options[:access] = path
path = path.path
end
@path = path
@repo_is_bare = options[:repo_is_bare]
@page_file_dir = options[:page_file_dir]
@access = options[:access] || GitAccess.new(path, @page_file_dir, @repo_is_bare)
@base_path = options[:base_path] || "/"
@page_class = options[:page_class] || self.class.page_class
@file_class = options[:file_class] || self.class.file_class
@markup_classes = options[:markup_classes] || self.class.markup_classes
@repo = @access.repo
@ref = options[:ref] || self.class.default_ref
@sanitization = options[:sanitization] || self.class.sanitization
@ws_subs = options[:ws_subs] ||
self.class.default_ws_subs
@history_sanitization = options[:history_sanitization] ||
self.class.history_sanitization
@live_preview = options.fetch(:live_preview, true)
@universal_toc = options.fetch(:universal_toc, false)
@mathjax = options[:mathjax] || false
# Use .fetch instead of ||
#
# o = { :a => false }
# o[:a] || true # => true
# o.fetch :a, true # => false
@path = path
@repo_is_bare = options.fetch :repo_is_bare, nil
@page_file_dir = options.fetch :page_file_dir, nil
@access = options.fetch :access, GitAccess.new(path, @page_file_dir, @repo_is_bare)
@base_path = options.fetch :base_path, "/"
@page_class = options.fetch :page_class, self.class.page_class
@file_class = options.fetch :file_class, self.class.file_class
@markup_classes = options.fetch :markup_classes, self.class.markup_classes
@repo = @access.repo
@ref = options.fetch :ref, self.class.default_ref
@sanitization = options.fetch :sanitization, self.class.sanitization
@ws_subs = options.fetch :ws_subs, self.class.default_ws_subs
@history_sanitization = options.fetch :history_sanitization, self.class.history_sanitization
@live_preview = options.fetch :live_preview, true
@universal_toc = options.fetch :universal_toc, false
@mathjax = options.fetch :mathjax, false
@show_all = options.fetch :show_all, false
@collapse_tree = options.fetch :collapse_tree, false
@css = options.fetch :css, false
@h1_title = options.fetch :h1_title, false
end
# Public: check whether the wiki's git repo exists on the filesystem.
@@ -588,6 +609,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.
+9
View File
@@ -1,3 +1,12 @@
For gollum code, everything should fall under the existing MIT License.
Alternative permissive licenses (such as BSD) for 3rd party dependencies are
acceptable. For image assets in Gollum, CC BY or CC BY-SA is fine. Anything
released under a copyleft license (for example GPL, AGPL, LGPL, MPL, EPL,
etc.) is not permitted in gollum. Public domain, CC BY or CC BY-SA for code in
gollum is not permitted.
---
The following PNGs are based on Ubuntu 11.10 SVG files located in /usr/share/icons/unity-icon-theme/places/svg/
- group-folders.svg
- group-files.svg
+1
View File
@@ -5,3 +5,4 @@ a8ad3c09dd842a3517085bfadd37718856dee813 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e
b16b3d9fad9d78e5a669e7f33d94c96da374eccd b0de6e794dfdc7ef3400e894225bfe23308aae5c kristi <kristi.dev@gmail.com> 1336984025 -0700 push
b0de6e794dfdc7ef3400e894225bfe23308aae5c cfea406f5f77afc7fb673a43e97721234385b1bd Darren Oakley <daz.oakley@gmail.com> 1341830099 +0100 push
cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc2 Darren Oakley <daz.oakley@gmail.com> 1341830833 +0100 push
629aa678272b017a4d136d35e77ac94d80b08dc2 7d6aeab8b84c895f21f6c66b84a457b0fced9693 Daniel Kimsey <dekimsey@ufl.edu> 1352501984 -0500 push
@@ -5,3 +5,4 @@ a8ad3c09dd842a3517085bfadd37718856dee813 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e
b16b3d9fad9d78e5a669e7f33d94c96da374eccd b0de6e794dfdc7ef3400e894225bfe23308aae5c kristi <kristi.dev@gmail.com> 1336984025 -0700 push
b0de6e794dfdc7ef3400e894225bfe23308aae5c cfea406f5f77afc7fb673a43e97721234385b1bd Darren Oakley <daz.oakley@gmail.com> 1341830099 +0100 push
cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc2 Darren Oakley <daz.oakley@gmail.com> 1341830833 +0100 push
629aa678272b017a4d136d35e77ac94d80b08dc2 7d6aeab8b84c895f21f6c66b84a457b0fced9693 Daniel Kimsey <dekimsey@ufl.edu> 1352501984 -0500 push
@@ -0,0 +1,2 @@
xEOK1 Å=÷S<ëEaºzEYð ]¼g·™™`¦•´3ê··ãù½—4ps}{¶=!gtä;°ö.„{wZNѹSÄ<g‹È=^eáYµCN¼vêȘdëlV¶²6³Æ6 
ã‰$q„$÷"1*&«c«!µ`?J? ¼Á“)øwšµ®°·JV|¿&!æ‰}ç²Áï´)<Ò—«þ¦cýƒHРs:²Õf£C»dŸõC8ah.Jß³qªˆl²P•ܤ›·ÿÁ§¶ï”«s¿³6gú
@@ -0,0 +1 @@
xÎ=j1@áÔ:Åt®ô?cC\ù³šY¼Ú ZmáÛ|„t¯ùà•­µy€õþct>èDh*q0Á°ËÅŠµbLbı+è²%õG]ÖÑf¢ˆÉ¢´Aòl\d‘Jöœô¤«è¿[‡ZgYà>·]žðÍòx×å¨Ë—ðqã‚ ÚdÌð©ƒÖª¼‡üǪ+³0Ü–¾­|Ú¡S š b¤^í/M1
+1 -1
View File
@@ -1 +1 @@
629aa678272b017a4d136d35e77ac94d80b08dc2
7d6aeab8b84c895f21f6c66b84a457b0fced9693
+4 -2
View File
@@ -1,3 +1,5 @@
<ol class="tree">
<li class="file"><a href="0">0</a></li>
</ol>
<li class="file">
<a href="0"><span class="icon"></span>0</a>
</li>
</ol>
+10 -7
View File
@@ -1,8 +1,11 @@
<ol class="tree">
<li>
<label>folder0</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="folder0/0">0</a></li>
</ol>
</li>
</ol>
<li>
<label>folder0</label>
<input type="checkbox" />
<ol>
<li class="file">
<a href="folder0/0"><span class="icon"></span>0</a>
</li>
</ol>
</li>
</ol>
+10 -7
View File
@@ -1,8 +1,11 @@
<ol class="tree">
<li>
<label>.</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="folder0">folder0</a></li>
</ol>
</li>
</ol>
<li>
<label>.</label>
<input type="checkbox" />
<ol>
<li class="file">
<a href="folder0"><span class="icon"></span>folder0</a>
</li>
</ol>
</li>
</ol>
+18 -10
View File
@@ -1,12 +1,20 @@
<ol class="tree">
<li>
<label>folder0</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="folder0/0">0</a></li>
</ol>
<li>
<label>folder0</label>
<input type="checkbox" />
<ol>
<li class="file">
<a href="folder0/0"><span class="icon"></span>0</a>
</li>
<li>
<label>folder1</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="folder1/1">1</a></li>
</ol>
</ol>
</li>
<li>
<label>folder1</label>
<input type="checkbox" />
<ol>
<li class="file">
<a href="folder1/1"><span class="icon"></span>1</a>
</li>
</ol>
</li>
</ol>
+21 -11
View File
@@ -1,13 +1,23 @@
<ol class="tree">
<li class="file"><a href="root">root</a></li>
<li>
<label>folder0</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="folder0/0">0</a></li>
</ol>
<li class="file">
<a href="root"><span class="icon"></span>root</a>
</li>
<li>
<label>folder0</label>
<input type="checkbox" />
<ol>
<li class="file">
<a href="folder0/0"><span class="icon"></span>0</a>
</li>
<li>
<label>folder1</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="folder1/1">1</a></li>
</ol>
</ol>
</li>
<li>
<label>folder1</label>
<input type="checkbox" />
<ol>
<li class="file">
<a href="folder1/1"><span class="icon"></span>1</a>
</li>
</ol>
</li>
</ol>
+35 -22
View File
@@ -1,28 +1,41 @@
<ol class="tree">
<li>
<label>folder0</label>
<input type="checkbox" />
<ol>
<li>
<label>folder0</label> <input type="checkbox" checked />
<label>folder1</label>
<input type="checkbox" />
<ol>
<li>
<label>folder1</label> <input type="checkbox" checked />
<ol>
<li>
<label>folder2</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="folder0/folder1/folder2/0">0</a></li>
<li>
<label>folder2</label>
<input type="checkbox" />
<ol>
<li class="file">
<a href="folder0/folder1/folder2/0"><span class="icon"></span>0</a>
</li>
</ol>
</li>
<li>
<label>folder3</label>
<input type="checkbox" />
<ol>
<li class="file">
<a href="folder0/folder1/folder3/1"><span class="icon"></span>1</a>
</li>
</ol>
</li>
</ol>
</li>
<li>
<label>folder3</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="folder0/folder1/folder3/1">1</a></li>
</ol>
</ol>
</li>
<li>
<label>folder4</label>
<input type="checkbox" />
<ol>
<li class="file">
<a href="folder4/2"><span class="icon"></span>2</a>
</li>
</ol>
</li>
</ol>
</li>
<li>
<label>folder4</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="folder4/2">2</a></li>
</ol>
</ol>
</li>
</ol>
+36
View File
@@ -185,6 +185,8 @@ context "Frontend" do
post "/create", :content => 'abc', :page => name,
:format => 'markdown', :message => 'def'
follow_redirect!
assert last_response.ok?
@wiki.clear_cache
@@ -260,6 +262,9 @@ context "Frontend" do
page2 = @wiki.page('A')
assert_equal page1.version.sha, page2.version.sha
end
=begin
# redirects are now handled by class MapGollum in bin/gollum
# they should be set in config.ru
test "redirects from 'base_path' or 'base_path/' to 'base_path/Home'" do
Precious::App.set(:wiki_options, {})
@@ -277,6 +282,7 @@ context "Frontend" do
# Reset base path
Precious::App.set(:wiki_options, { :base_path => nil })
end
=end
test "author details in session are used" do
page1 = @wiki.page('A')
@@ -363,6 +369,36 @@ context "Frontend with lotr" do
assert body.include?("Eye Of Sauron"), "/pages/Mordor/ should include the page 'Eye Of Sauron'"
end
# base path requires 'map' in a config.ru to work correctly.
test "create pages within sub-directories using base path" do
Precious::App.set(:wiki_options, { :base_path => 'wiki' })
page = 'path'
post "/create", :content => '123', :page => page,
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
# should be wiki/Mordor/path
assert_equal 'http://example.org/Mordor/' + page, last_response.headers['Location']
get '/Mordor/' + page
assert_match /123/, last_response.body
# Reset base path
Precious::App.set(:wiki_options, { :base_path => nil })
end
test "create pages within sub-directories using page file dir" do
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
post "/create", :content => 'big smelly creatures', :page => 'Orc',
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
+1 -1
View File
@@ -50,7 +50,7 @@ context "Wiki" do
end
test "parents with default master ref" do
ref = '629aa678272b017a4d136d35e77ac94d80b08dc2'
ref = '7d6aeab8b84c895f21f6c66b84a457b0fced9693'
committer = Gollum::Committer.new(@wiki)
assert_equal ref, committer.parents.first.sha
end
+19 -1
View File
@@ -12,6 +12,10 @@ class FakePage
::File.basename(@filepath, ::File.extname(@filepath))
end
def filename
::File.basename(@filepath)
end
def path
return @filepath
end
@@ -64,10 +68,24 @@ def write file, content
end
end
def to_html html
# Remove blank nodes for proper formatting
doc = Nokogiri.XML(html) do |cfg|
cfg.default_xml.noblanks
end
# Save as XHTML
doc.to_xml( { :save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML, :indent => 2, :encoding => 'UTF-8' } )
end
def check name, pages_array
pages = FakePages.new pages_array
expected = read name
actual = view pages
actual = to_html view pages
# Uncomment when updating tests
# write name, actual
assert_equal expected, actual
end
+1 -1
View File
@@ -18,7 +18,7 @@ context "GitAccess" do
assert @access.ref_map.empty?
assert @access.tree_map.empty?
@access.tree 'master'
assert_equal({"master"=>"629aa678272b017a4d136d35e77ac94d80b08dc2"}, @access.ref_map)
assert_equal({"master"=>"7d6aeab8b84c895f21f6c66b84a457b0fced9693"}, @access.ref_map)
@access.tree '1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3'
map = @access.tree_map['1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3']
+2 -4
View File
@@ -25,15 +25,13 @@ context "gitcode" do
end
test 'that the rendered output is correctly fetched and rendered as html code' do
assert_equal %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"nt\">&lt;ol</span> <span class=\"na\">class=</span><span class=\"s\">\"tree\"</span><span class=\"nt\">&gt;</span>\n <span class=\"nt\">&lt;li</span> <span class=\"na\">class=</span><span class=\"s\">\"file\"</span><span class=\"nt\">&gt;&lt;a</span> <span class=\"na\">href=</span><span class=\"s\">\"0\"</span><span class=\"nt\">&gt;</span>0<span class=\"nt\">&lt;/a&gt;&lt;/li&gt;</span>\n<span class=\"nt\">&lt;/ol&gt;</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\">&lt;ol</span> <span class=\"na\">class=</span><span class=\"s\">\"tree\"</span><span class=\"nt\">&gt;</span>\n <span class=\"nt\">&lt;li</span> <span class=\"na\">class=</span><span class=\"s\">\"file\"</span><span class=\"nt\">&gt;</span>\n <span class=\"nt\">&lt;a</span> <span class=\"na\">href=</span><span class=\"s\">\"0\"</span><span class=\"nt\">&gt;&lt;span</span> <span class=\"na\">class=</span><span class=\"s\">\"icon\"</span><span class=\"nt\">&gt;&lt;/span&gt;</span>0<span class=\"nt\">&lt;/a&gt;</span>\n <span class=\"nt\">&lt;/li&gt;</span>\n<span class=\"nt\">&lt;/ol&gt;</span>\n</pre></div>\n\n<p>b</p>}, @rendered
end
test 'contents' do
g = Gollum::Gitcode.new 'github/gollum/master/test/file_view/1_file.txt'
assert_equal g.contents, %{<ol class="tree">
<li class="file"><a href="0">0</a></li>
</ol>}
assert_equal g.contents, %{<ol class=\"tree\">\n <li class=\"file\">\n <a href=\"0\"><span class=\"icon\"></span>0</a>\n </li>\n</ol>\n}
end
teardown do
+45 -20
View File
@@ -193,7 +193,7 @@ context "Markup" do
test "wiki link within inline code block" do
@wiki.write_page("Potato", :markdown, "`sed -i '' 's/[[:space:]]*$//'`", commit_details)
page = @wiki.page("Potato")
assert_equal "<p>\n <code>sed -i '' 's/[[:space:]]*$//'</code>\n</p>", page.formatted_data
assert_equal "<p><code>sed -i '' 's/[[:space:]]*$//'</code></p>", page.formatted_data
end
test "regexp gsub! backref (#383)" do
@@ -208,11 +208,24 @@ context "Markup" do
DATA
), commit_details)
output = @wiki.page(page).formatted_data
expected = %Q{<pre>\n <code> <div class=\"highlight\"><pre><span class=\"n\">rot13</span><span class=\"p\">=</span><span class=\"s\">'tr '</span><span class=\"o\">\\</span><span class=\"s\">''</span><span class=\"n\">A</span><span class=\"o\">-</span><span class=\"n\">Za</span><span class=\"o\">-</span><span class=\"n\">z</span><span class=\"o\">'\\</span><span class=\"s\">''</span> <span class=\"s\">'\\''N-ZA-Mn-za-m'</span><span class=\"o\">\\</span><span class=\"s\">'</span>\n</pre></div>\n</code>\n</pre>}
expected = %Q{<pre><code> <div class=\"highlight\"><pre><span class=\"n\">rot13</span><span class=\"p\">=</span><span class=\"s\">'tr '</span><span class=\"o\">\\</span><span class=\"s\">''</span><span class=\"n\">A</span><span class=\"o\">-</span><span class=\"n\">Za</span><span class=\"o\">-</span><span class=\"n\">z</span><span class=\"o\">'\\</span><span class=\"s\">''</span> <span class=\"s\">'\\''N-ZA-Mn-za-m'</span><span class=\"o\">\\</span><span class=\"s\">'</span>\n</pre></div>\n</code></pre>}
assert_equal expected, output
end
test "~~~ code blocks #537" do
# Issue #568
test "tilde code blocks without a language" do
page = 'test_rgx'
@wiki.write_page(page, :markdown,
%Q(~~~
'hi'
~~~
), commit_details)
output = @wiki.page(page).formatted_data
expected = %Q{<div class=\"highlight\"><pre><span class=\"s\">'hi'</span>\n</pre></div>}
assert_equal expected, output
end
test "tilde code blocks #537" do
page = 'test_rgx'
@wiki.write_page(page, :markdown,
%Q(~~~ {.ruby}
@@ -220,11 +233,12 @@ context "Markup" do
~~~
), commit_details)
output = @wiki.page(page).formatted_data
expected = %Q{<div class=\"highlight\">\n <pre><span class=\"s1\">'hi'</span>\n</pre>\n</div>}
expected = %Q{<div class=\"highlight\"><pre><span class=\"s1\">'hi'</span>\n</pre></div>}
assert_equal expected, output
end
test "~~~ code blocks #537 with more than one class" do
# Issue #537
test "tilde code blocks with more than one class" do
page = 'test_rgx'
@wiki.write_page(page, :markdown,
%Q(~~~ {#hi .ruby .sauce}
@@ -232,11 +246,12 @@ context "Markup" do
~~~
), commit_details)
output = @wiki.page(page).formatted_data
expected = %Q{<div class=\"highlight\">\n <pre><span class=\"s1\">'hi'</span>\n</pre>\n</div>}
expected = %Q{<div class=\"highlight\"><pre><span class=\"s1\">'hi'</span>\n</pre></div>}
assert_equal expected, output
end
test "~~~ code blocks #537 with lots of tildes" do
# Issue #537
test "tilde code blocks with lots of tildes" do
page = 'test_rgx'
@wiki.write_page(page, :markdown,
%Q(~~~~~~ {#hi .ruby .sauce}
@@ -245,20 +260,30 @@ context "Markup" do
~~~~~~
), commit_details)
output = @wiki.page(page).formatted_data
expected = %Q{<div class=\"highlight\">\n <pre><span class=\"o\">~~</span>\n<span class=\"s1\">'hi'</span><span class=\"o\">~</span>\n</pre>\n</div>}
expected = %Q{<div class=\"highlight\"><pre><span class=\"o\">~~</span>\n<span class=\"s1\">'hi'</span><span class=\"o\">~</span>\n</pre></div>}
assert_equal expected, output
end
test "four space indented code block" do
page = 'test_four'
@wiki.write_page(page, :markdown,
%( test
test), commit_details)
output = @wiki.page(page).formatted_data
expected = %(<pre><code>test\ntest\n</code></pre>)
assert_equal expected, output
end
test "wiki link within code block" do
@wiki.write_page("Potato", :markdown, " sed -i '' 's/[[:space:]]*$//'", commit_details)
page = @wiki.page("Potato")
assert_equal "<pre>\n <code>sed -i '' 's/[[:space:]]*$//'\n</code>\n</pre>", page.formatted_data
assert_equal "<pre><code>sed -i '' 's/[[:space:]]*$//'\n</code></pre>", page.formatted_data
end
test "piped wiki link within code block" do
@wiki.write_page("Potato", :markdown, "`make a link [[home|sweet home]]`", commit_details)
page = @wiki.page("Potato")
assert_equal "<p>\n <code>make a link [[home|sweet home]]</code>\n</p>", page.formatted_data
assert_equal "<p><code>make a link [[home|sweet home]]</code></p>", page.formatted_data
end
#########################################################################
@@ -459,9 +484,9 @@ context "Markup" do
#
#########################################################################
test "code blocks" do
test "regular code blocks" do
content = "a\n\n```ruby\nx = 1\n```\n\nb"
output = %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre>\n</div>\n\n<p>b</p>}
output = %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre></div>\n\n<p>b</p>}
index = @wiki.repo.index
index.add("Bilbo-Baggins.md", content)
@@ -474,7 +499,7 @@ context "Markup" do
test "code blocks with carriage returns" do
content = "a\r\n\r\n```ruby\r\nx = 1\r\n```\r\n\r\nb"
output = %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre>\n</div>\n\n<p>b</p>}
output = %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre></div>\n\n<p>b</p>}
index = @wiki.repo.index
index.add("Bilbo-Baggins.md", content)
@@ -505,7 +530,7 @@ context "Markup" do
test "code blocks with multibyte caracters indent" do
content = "a\n\n```ruby\ns = 'やくしまるえつこ'\n```\n\nb"
output = %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"n\">s</span> <span class=\"o\">=</span> <span class=\"s1\">'やくしまるえつこ'</span>\n</pre>\n</div>\n\n<p>b</p>}
output = %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"n\">s</span> <span class=\"o\">=</span> <span class=\"s1\">'やくしまるえつこ'</span>\n</pre></div>\n\n<p>b</p>}
index = @wiki.repo.index
index.add("Bilbo-Baggins.md", content)
index.commit("Add alpha.jpg")
@@ -565,7 +590,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\">\n <pre><span class=\"nt\">&lt;p&gt;</span>a b<span class=\"nt\">&lt;/p&gt;</span>\n</pre>\n</div>}, output_page
assert_equal %Q{<div class=\"highlight\"><pre><span class=\"nt\">&lt;p&gt;</span>a b<span class=\"nt\">&lt;/p&gt;</span>\n</pre></div>}, output_page
end
test "embed code page absolute link" do
@@ -574,7 +599,7 @@ np.array([[2,2],[1,3]],np.float)
page = @wiki.page("a")
output = page.formatted_data
assert_equal %Q{<p>a\n</p><div class=\"highlight\">\n <pre><span class=\"nt\">&lt;p&gt;</span>a\n!base<span class=\"nt\">&lt;/p&gt;</span>\n</pre>\n</div>\n}, output
assert_equal %Q{<p>a\n</p><div class=\"highlight\"><pre><span class=\"nt\">&lt;p&gt;</span>a\n!base<span class=\"nt\">&lt;/p&gt;</span>\n</pre></div>\n}, output
end
test "embed code page relative link" do
@@ -583,7 +608,7 @@ np.array([[2,2],[1,3]],np.float)
page = @wiki.page("a")
output = page.formatted_data
assert_equal %Q{<p>a\n</p><div class=\"highlight\">\n <pre><span class=\"nt\">&lt;p&gt;</span>a\n!rel<span class=\"nt\">&lt;/p&gt;</span>\n</pre>\n</div>\n}, output
assert_equal %Q{<p>a\n</p><div class=\"highlight\"><pre><span class=\"nt\">&lt;p&gt;</span>a\n!rel<span class=\"nt\">&lt;/p&gt;</span>\n</pre></div>\n}, output
end
test "code block in unsupported language" do
@@ -631,7 +656,7 @@ np.array([[2,2],[1,3]],np.float)
page = @wiki.page("Bilbo Baggins")
rendered = Gollum::Markup.new(page).render
assert_equal output, rendered
assert_equal result, page.meta_data
assert_equal result, page.metadata
end
test "metadata blocks with newline" do
@@ -646,7 +671,7 @@ np.array([[2,2],[1,3]],np.float)
page = @wiki.page("Bilbo Baggins")
rendered = Gollum::Markup.new(page).render
assert_equal output, rendered
assert_equal result, page.meta_data
assert_equal result, page.metadata
end
test "metadata sanitation" do
@@ -661,7 +686,7 @@ np.array([[2,2],[1,3]],np.float)
page = @wiki.page("Bilbo Baggins")
rendered = Gollum::Markup.new(page).render
assert_equal output, rendered
assert_equal result, page.meta_data
assert_equal result, page.metadata
end
#########################################################################
+7
View File
@@ -227,5 +227,12 @@ context "within a sub-directory" do
assert page.header.raw_data =~ /^Hobbits/
assert page.footer.raw_data =~ /^Lord of the Rings/
end
test "get metadata on page" do
page = @wiki.page('Elrond')
assert_equal Gollum::Page, page.class
assert_equal 'elf', page.metadata['race']
end
end
+8
View File
@@ -198,6 +198,14 @@ context "Wiki page writing" do
assert_equal cd[:email], @wiki.repo.commits.first.author.email
end
test "page title override with metadata" do
@wiki.write_page("Gollum", :markdown, "<!-- --- title: Over -->", commit_details)
page = @wiki.page("Gollum")
assert_equal 'Over', page.url_path_title
end
test "update page with format change" do
@wiki.write_page("Gollum", :markdown, "# Gollum", commit_details)