Compare commits

..

27 Commits

Author SHA1 Message Date
bootstraponline b76fef9143 Update version to 2.1.3 2012-08-13 11:37:56 -06:00
bootstraponline e935af83d5 Update gemspec. 2012-08-13 11:35:15 -06:00
bootstraponline d4e019ef42 Merge pull request #331 from tjh/home-page-link-issue
Redirect from root to /Home, fixes #250
2012-08-09 10:41:31 -07:00
bootstraponline 2e738828c6 Merge pull request #467 from jamesduncombe/pygments_initialize
Added Pygments.start to initialize Pygments on startup, fixes #465
2012-08-09 10:21:59 -07:00
James Duncombe fd7dc93778 Added Pygments.start to initialize Pygments on startup 2012-08-09 09:14:55 +01:00
bootstraponline 3df407d9ee Merge pull request #464 from giga/master
Fix editor when base url is '/'
2012-08-08 10:53:45 -07:00
Jean-Philippe Garcia Ballester 6fbba84725 Revert "Base path is relative."
This reverts commit 69e453ea0b.
2012-08-08 13:49:11 +02:00
Jean-Philippe Garcia Ballester 37d20fa9cc Base url without trailing '/'
This will allow cleaner url in templates and javascripts.
2012-08-08 13:49:09 +02:00
bootstraponline 410cd912ac Fix releasing. 2012-08-06 18:31:36 -06:00
bootstraponline d234bbd861 Test get %r{/(.+?)/([0-9a-f]{40})} do 2012-08-06 18:27:12 -06:00
Corey Donohoe 3f68d96815 setup proper gem version numbers 2012-08-06 16:32:16 -07:00
bootstraponline 015cd895d2 Don't ignore version. 2012-08-06 17:18:30 -06:00
bootstraponline 5fa4b48d85 Fix new page default dir. 2012-08-06 15:57:46 -06:00
bootstraponline 88a3783bbc Remove wpage. 2012-08-06 15:55:05 -06:00
bootstraponline ea2254b9bd Fix #462.
Add test for 462.
2012-08-06 15:52:19 -06:00
bootstraponline 9a0c1f2605 Fix path. 2012-08-06 15:18:15 -06:00
bootstraponline 008f26bb7d Fix app. 2012-08-06 14:49:56 -06:00
bootstraponline 69e453ea0b Base path is relative. 2012-08-06 14:28:24 -06:00
bootstraponline 88b0b608f4 Add null guard. 2012-08-06 13:49:48 -06:00
bootstraponline 19e3987ae3 Fix path escaping. 2012-08-06 13:36:28 -06:00
bootstraponline c72e91ddaf Fix #462. 2012-08-06 13:16:31 -06:00
bootstraponline c789dd5067 Update org-ruby. 2012-08-02 19:45:06 -06:00
bootstraponline 551949de29 Fix #459. 2012-08-02 16:55:24 -06:00
bootstraponline 80730ee87a Merge pull request #419 from trans/metadata
Add support for embedded page metadata.
2012-08-01 16:05:10 -07:00
trans 71028adc9e Add support for embedded page metadata. 2012-08-01 18:35:53 -04:00
bootstraponline a2efebc06c Fix #453. 2012-08-01 13:04:04 -06:00
Tim Harvey 43d2143506 Redirect from root to /Home, fixes #250 2012-05-10 08:55:56 -04:00
22 changed files with 214 additions and 62 deletions
+3 -1
View File
@@ -520,8 +520,10 @@ your changes merged back into core is as follows:
1. Send a pull request to the github/gollum project.
## RELEASING
Update VERSION in lib/gollum.rb
$ rake gemspec
$ git tag vX.Y.Z
$ git push origin vX.Y.Z
$ gem build gollum.gemspec
$ gem push gollum-X.Y.Z.gem
+3 -3
View File
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
s.required_ruby_version = ">= 1.8.7"
s.name = 'gollum'
s.version = '2.1.0'
s.date = '2012-08-01'
s.version = '2.1.3'
s.date = '2012-08-13'
s.rubyforge_project = 'gollum'
s.summary = "A simple, Git-powered wiki."
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
s.add_development_dependency('RedCloth')
s.add_development_dependency('mocha')
s.add_development_dependency('org-ruby', '~>0.6.3')
s.add_development_dependency('org-ruby', '~> 0.7.0')
s.add_development_dependency('shoulda')
s.add_development_dependency('rack-test')
s.add_development_dependency('wikicloth', '~>0.8.0')
+1 -1
View File
@@ -22,7 +22,7 @@ require File.expand_path('../gollum/tex', __FILE__)
require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
module Gollum
VERSION = '2.1.0'
VERSION = '2.1.3'
def self.assets_path
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
+15 -11
View File
@@ -82,20 +82,24 @@ module Precious
end
before do
@base_url = settings.wiki_options.has_key?(:base_url) ? settings.wiki_options[:base_url] : url('/')
@base_url = url('/', false).chomp('/')
settings.wiki_options.merge!({ :base_path => @base_url }) unless settings.wiki_options.has_key? :base_path
end
get '/' do
show_page_or_file('Home')
redirect File.join(settings.wiki_options[:base_path].to_s, 'Home')
end
# path is set to name if path is nil.
# if path is 'a/b' and a and b are dirs, then
# path must have a trailing slash 'a/b/' or
# extract_path will trim path to 'a'
# name, path, version
def wiki_page( name, path = nil, version = nil)
path = name if path.nil?
name = extract_name(name)
path = extract_path(path)
wiki = wiki_new
OpenStruct.new(:wiki => wiki, :page => wiki.paged(name, path, version),
@@ -137,7 +141,7 @@ module Precious
end
post '/edit/*' do
wikip = wiki_page(CGI.unescape(params[:page]), sanitize_empty_params(params[:path]))
wikip = wiki_page(CGI.unescape(params[:page]), sanitize_empty_params(params[:path]))
path = wikip.path
wiki = wikip.wiki
page = wikip.page
@@ -168,9 +172,8 @@ module Precious
end
get '/create/*' do
splat = params[:splat].first
wikip = wiki_page(extract_name(splat).to_url, splat)
@name = wikip.name
wikip = wiki_page(params[:splat].first)
@name = wikip.name.to_url
@path = wikip.path
page = wikip.page
@@ -193,7 +196,7 @@ module Precious
begin
wiki.write_page(name, format, params[:content], commit_message)
page = wiki.page(name)
redirect to("/#{page.escaped_url_path}")
redirect to("/#{page.escaped_url_path}") unless page.nil?
rescue Gollum::DuplicatePageError => e
@message = "Duplicate page: #{e.message}"
mustache :error
@@ -285,10 +288,11 @@ module Precious
get %r{/(.+?)/([0-9a-f]{40})} do
file_path = params[:captures][0]
name = extract_name(file_path)
path = extract_path(file_path)
version = params[:captures][1]
if page = wiki_page(name, path, version).page
wikip = wiki_page(file_path, file_path, version)
name = wikip.name
path = wikip.path
if page = wikip.page
@page = page
@name = name
@content = page.formatted_data
@@ -167,7 +167,7 @@
setActiveLanguage: function( name ) {
// On first load _ACTIVE_LANG.length is 0 and evtChangeFormat isn't called.
if ( LanguageDefinition._ACTIVE_LANG.length <= 0 ) {
if ( LanguageDefinition._ACTIVE_LANG != null && LanguageDefinition._ACTIVE_LANG.length <= 0 ) {
FormatSelector.updateCommitMessage( name );
}
@@ -4,7 +4,7 @@ $(document).ready(function() {
var ok = confirm($(this).data('confirm'));
if ( ok ) {
var loc = window.location;
loc = baseUrl + 'delete' + loc.pathname
loc = baseUrl + '/delete' + loc.pathname
window.location = loc;
}
// Don't navigate on cancel.
@@ -138,7 +138,7 @@ $(document).ready(function() {
var msg = 'Renamed ' + oldName + ' to ' + newName;
jQuery.ajax( {
type: 'POST',
url: baseUrl + 'edit/' + oldName,
url: baseUrl + '/edit/' + oldName,
data: { path: path, rename: newName, page: oldName, message: msg },
success: function() {
window.location = baseUrl + encodeURIComponent(newName);
@@ -157,7 +157,7 @@ $(document).ready(function() {
var path = location.pathname;
// ensure there's more than one slash in pathname.
if (path.split('/').length > 2) {
path = path.substr(path.lastIndexOf('/')+1) + '/';
path = path.substr(0, path.lastIndexOf('/') + 1);
} else {
path = '';
}
@@ -99,8 +99,10 @@ $.save = function( commitMessage ) {
var msg = defaultCommitMessage();
var newLocation = location.protocol + '//' + location.host + baseUrl;
// 'a%2Fb' => a/b
if (pathName) {
newLocation += '/' + pathName;
newLocation += '/' + unescape(pathName);
pathName = pathName + '/'; // pathName must end with /
}
newLocation += '/' + pageName;
@@ -6,11 +6,11 @@
<li class="minibutton">
{{>searchbar}}
</li>
<li class="minibutton"><a href="{{base_url}}{{escaped_url_path}}"
<li class="minibutton"><a href="{{base_url}}/{{escaped_url_path}}"
class="action-view-page">View Page</a></li>
<li class="minibutton"><a href="{{base_url}}edit/{{escaped_url_path}}"
<li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
class="action-edit-page">Edit Page</a></li>
<li class="minibutton"><a href="{{base_url}}history/{{escaped_url_path}}"
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
class="action-page-history">Page History</a></li>
</ul>
</div>
@@ -23,10 +23,10 @@
{{#show_revert}}
<ul class="actions">
<li class="minibutton"><a href="{{base_url}}history/{{escaped_url_path}}"
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
class="action-page-history">Back to Page History</a></li>
<li class="minibutton">
<form name="gollum-revert" action="{{base_url}}revert/{{escaped_url_path}}/{{before}}/{{after}}" method="post" id="gollum-revert-form">
<form name="gollum-revert" action="{{base_url}}/revert/{{escaped_url_path}}/{{before}}/{{after}}" method="post" id="gollum-revert-form">
<a href="#" class="gollum-revert-button">Revert Changes</a>
</form>
</li>
@@ -49,7 +49,7 @@
</div>
<div id="footer">
<ul class="actions">
<li class="minibutton"><a href="{{base_url}}history/{{escaped_url_path}}"
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
class="action-page-history">Back to Page History</a></li>
{{#show_revert}}
<li class="minibutton">
+2 -2
View File
@@ -2,9 +2,9 @@
<div id="head">
<h1>Editing <strong>{{title}}</strong></h1>
<ul class="actions">
<li class="minibutton"><a href="{{base_url}}{{escaped_url_path}}"
<li class="minibutton"><a href="{{base_url}}/{{escaped_url_path}}"
class="action-view-page">View Page</a></li>
<li class="minibutton"><a href="{{base_url}}history/{{escaped_url_path}}"
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
class="action-page-history">Page History</a></li>
</ul>
</div>
@@ -1,9 +1,9 @@
<div id="gollum-editor" data-escaped-name="{{escaped_name}}" class="{{#is_create_page}}create{{/is_create_page}}{{#is_edit_page}}edit{{/is_edit_page}}">
{{#is_create_page}}
<form name="gollum-editor" action="{{base_url}}create" method="post">
<form name="gollum-editor" action="{{base_url}}/create" method="post">
{{/is_create_page}}
{{#is_edit_page}}
<form name="gollum-editor" action="{{base_url}}edit/{{escaped_name}}" method="post">
<form name="gollum-editor" action="{{base_url}}/edit/{{escaped_name}}" method="post">
{{/is_edit_page}}
<fieldset id="gollum-editor-fields">
{{#is_create_page}}
@@ -126,7 +126,7 @@
<span class="jaws"><br></span>
<input type="submit" id="gollum-editor-submit" value="Save" title="Save current changes">
<a href="{{base_url}}preview" id="gollum-editor-preview" class="minibutton" title="Preview this Page">Preview</a>
<a href="{{base_url}}/preview" id="gollum-editor-preview" class="minibutton" title="Preview this Page">Preview</a>
</fieldset>
</form>
</div>
@@ -2,9 +2,9 @@
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=utf-8">
<link rel="stylesheet" type="text/css" href="{{base_url}}css/gollum.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}css/template.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}css/_styles.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/gollum.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/template.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/_styles.css" media="all">
<title>{{title}}</title>
</head>
<body>
@@ -12,7 +12,7 @@
<div id="home_button">
<ul class="actions">
<li class="minibutton">
<a href="{{base_url}}" class="action-edit-page">Home</a>
<a href="{{base_url}}/" class="action-edit-page">Home</a>
</li>
</ul>
</div>
@@ -5,9 +5,9 @@
<li class="minibutton">
{{>searchbar}}
</li>
<li class="minibutton"><a href="{{base_url}}{{escaped_url_path}}"
<li class="minibutton"><a href="{{base_url}}/{{escaped_url_path}}"
class="action-view-page">View Page</a></li>
<li class="minibutton"><a href="{{base_url}}edit/{{escaped_url_path}}"
<li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
class="action-edit-page">Edit Page</a></li>
</ul>
</div>
@@ -19,7 +19,7 @@
</ul>
<form name="compare-versions" id="version-form" method="post"
action="{{base_url}}compare/{{escaped_url_path}}">
action="{{base_url}}/compare/{{escaped_url_path}}">
<fieldset>
<table>
<tbody>
@@ -39,7 +39,7 @@
<td class="commit-name">
<span class="time-elapsed">{{date}}:</span>&nbsp;
{{message}}
[<a href="{{base_url}}{{escaped_url_path}}/{{id}}" title="View commit">{{id7}}</a>]
[<a href="{{base_url}}/{{escaped_url_path}}/{{id}}" title="View commit">{{id7}}</a>]
</td>
</tr>
{{/versions}}
+11 -11
View File
@@ -2,22 +2,22 @@
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=utf-8">
<link rel="stylesheet" type="text/css" href="{{base_url}}css/gollum.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}css/editor.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}css/dialog.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}css/template.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/gollum.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/editor.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/dialog.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/template.css" media="all">
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="{{base_url}}css/ie7.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/ie7.css" media="all">
<![endif]-->
<script>var baseUrl = '{{base_url}}'</script>
<script type="text/javascript" src="{{base_url}}javascript/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="{{base_url}}javascript/mousetrap.min.js"></script>
<script type="text/javascript" src="{{base_url}}javascript/gollum.js"></script>
<script type="text/javascript" src="{{base_url}}javascript/gollum.dialog.js"></script>
<script type="text/javascript" src="{{base_url}}javascript/gollum.placeholder.js"></script>
<script type="text/javascript" src="{{base_url}}javascript/editor/gollum.editor.js"></script>
<script type="text/javascript" src="{{base_url}}/javascript/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="{{base_url}}/javascript/mousetrap.min.js"></script>
<script type="text/javascript" src="{{base_url}}/javascript/gollum.js"></script>
<script type="text/javascript" src="{{base_url}}/javascript/gollum.dialog.js"></script>
<script type="text/javascript" src="{{base_url}}/javascript/gollum.placeholder.js"></script>
<script type="text/javascript" src="{{base_url}}/javascript/editor/gollum.editor.js"></script>
{{#mathjax}}<script>(function(d,j){
j = d.createElement('script');
j.src = 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
+6 -6
View File
@@ -5,21 +5,21 @@
<li class="minibutton">
{{>searchbar}}
</li>
<li class="minibutton"><a href="{{base_url}}"
<li class="minibutton"><a href="{{base_url}}/"
class="action-edit-page">Home</a></li>
<li class="minibutton"><a href="{{base_url}}pages"
<li class="minibutton"><a href="{{base_url}}/pages"
class="action-all-pages">All</a></li>
<li class="minibutton"><a href="{{base_url}}fileview"
<li class="minibutton"><a href="{{base_url}}/fileview"
class="action-all-pages">Files</a></li>
<li class="minibutton" class="jaws">
<a href="#" id="minibutton-new-page">New</a></li>
<li class="minibutton" class="jaws">
<a href="#" id="minibutton-rename-page">Rename</a></li>
{{#editable}}
<li class="minibutton"><a href="{{base_url}}edit/{{escaped_url_path}}"
<li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
class="action-edit-page">Edit</a></li>
{{/editable}}
<li class="minibutton"><a href="{{base_url}}history/{{escaped_url_path}}"
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
class="action-page-history">History</a></li>
</ul>
</div>
@@ -62,7 +62,7 @@
<div id="footer">
<p id="last-edit">Last edited by <b>{{author}}</b>, {{date}}</p>
<p>
<a id="delete-link" href="{{base_url}}{{escaped_url_path}}" data-confirm="Are you sure you want to delete this page?"><span>Delete this Page</span></a>
<a id="delete-link" href="{{base_url}}/{{escaped_url_path}}" data-confirm="Are you sure you want to delete this page?"><span>Delete this Page</span></a>
</p>
</div>
</div>
+1 -1
View File
@@ -5,7 +5,7 @@
<li class="minibutton">
{{>searchbar}}
</li>
<li class="minibutton"><a href="{{base_url}}"
<li class="minibutton"><a href="{{base_url}}/"
class="action-edit-page">Home</a></li>
<li class="minibutton" class="jaws">
<a href="#" id="minibutton-new-page">New</a>
@@ -5,7 +5,7 @@
<li class="minibutton">
{{>searchbar}}
</li>
<li class="minibutton"><a href="{{base_url}}"
<li class="minibutton"><a href="{{base_url}}/"
class="action-edit-page">Home</a></li>
</ul>
</div>
@@ -15,7 +15,7 @@
<ul>
{{#results}}
<li>
<a href="{{base_url}}{{name}}">{{name}}</a>
<a href="{{base_url}}/{{name}}">{{name}}</a>
<span class="count">({{count}} matches)</span>
</li>
{{/results}}
@@ -1,5 +1,5 @@
<div id="searchbar">
<form action="{{base_url}}search" method="get" id="search-form">
<form action="{{base_url}}/search" method="get" id="search-form">
<div id="searchbar-fauxtext">
<input type="text" name="q" id="search-query" value="Search&hellip;" autocomplete="off">
<a href="#" id="search-submit" title="Search this wiki">
+11
View File
@@ -79,6 +79,17 @@ module Precious
def mathjax
@mathjax
end
# Access to embedded metadata.
#
# Examples
#
# {{#metadata}}{{name}}{{/metadata}}
#
# Returns Hash.
def metadata
@page.metadata
end
end
end
end
+31 -1
View File
@@ -3,10 +3,15 @@ require 'cgi'
require 'pygments'
require 'base64'
# initialize Pygments
Pygments.start
module Gollum
class Markup
attr_accessor :toc
attr_reader :metadata
# Initialize a new Markup object.
#
# page - The Gollum::Page.
@@ -27,6 +32,7 @@ module Gollum
@wsdmap = {}
@premap = {}
@toc = nil
@metadata = nil
end
# Render the content with Gollum wiki syntax on top of the file's own
@@ -43,6 +49,7 @@ module Gollum
@wiki.sanitizer
data = @data.dup
data = extract_metadata(data)
data = extract_code(data)
data = extract_tex(data)
data = extract_wsd(data)
@@ -399,7 +406,7 @@ module Gollum
link_name = @wiki.page_class.cname(page.name)
presence = "present"
end
link = ::File.join(@wiki.base_path, CGI.escape(link_name))
link = ::File.join(@wiki.base_path, page ? page.escaped_url_path : CGI.escape(link_name))
%{<a class="internal #{presence}" href="#{link}#{extra}">#{name}</a>}
end
end
@@ -565,6 +572,29 @@ module Gollum
data
end
#########################################################################
#
# Metadata
#
#########################################################################
# Extract metadata for data and build metadata table. Metadata
# is content found between `<!-- ---` and `-->` markers, and must
# be a valid YAML mapping.
#
# Returns the String of formatted data with metadata removed.
def extract_metadata(data)
@metadata ||= {}
data.gsub(/\<\!--+\s+---(.*?)--+\>/m) do
yaml = @wiki.sanitizer.clean($1)
hash = YAML.load(yaml)
if Hash === hash
@metadata.update(hash)
end
''
end
end
# Hook for getting the formatted value of extracted tag data.
#
# type - Symbol value identifying what type of data is being extracted.
+8
View File
@@ -217,6 +217,14 @@ module Gollum
markup_class.toc
end
# Public: Embedded metadata.
#
# Returns Hash of metadata.
def meta_data()
formatted_data if markup_class.metadata == nil
markup_class.metadata
end
# Public: The format of the page.
#
# Returns the Symbol format of the page. One of:
+44
View File
@@ -142,6 +142,36 @@ context "Frontend" do
assert last_response.ok?
end
test "page create and edit with dash & page rev" do
page = 'c-d-e'
path = 'a/b/' # path must end with /
post '/create', :content => 'create_msg', :page => page,
:path => path, :format => 'markdown', :message => ''
page_c = @wiki.paged(page, path)
assert_equal 'create_msg', page_c.raw_data
# must clear or create_msg will be returned
@wiki.clear_cache
# post '/edit' fails. post '/edit/' works.
post '/edit/', :content => 'edit_msg',
:page => page, :path => path, :message => ''
page_e = @wiki.paged(page, path)
assert_equal 'edit_msg', page_e.raw_data
@wiki.clear_cache
# test `get %r{/(.+?)/([0-9a-f]{40})} do` in app.rb
get '/' + page_c.escaped_url_path + '/' + page_c.version.to_s
assert last_response.ok?
assert_match /create_msg/, last_response.body
get '/' + page_e.escaped_url_path + '/' + page_e.version.to_s
assert last_response.ok?
assert_match /edit_msg/, last_response.body
end
test "guards against creation of existing page" do
name = "A"
post "/create", :content => 'abc', :page => name,
@@ -219,6 +249,20 @@ context "Frontend" do
assert_equal page1.version.sha, page2.version.sha
end
test "redirects from 'base_path' or 'base_path/' to 'base_path/Home'" do
Precious::App.set(:wiki_options, {})
get "/"
assert_match "http://example.org/Home", last_response.headers['Location']
Precious::App.set(:wiki_options, { :base_path => '/wiki' })
get "/"
assert_match "http://example.org/wiki/Home", last_response.headers['Location']
Precious::App.set(:wiki_options, { :base_path => '/wiki/' })
get "/"
assert_match "http://example.org/wiki/Home", last_response.headers['Location']
end
def app
Precious::App
end
+51
View File
@@ -517,6 +517,57 @@ np.array([[2,2],[1,3]],np.float)
assert_not_nil rendered.match(output)
end
#########################################################################
#
# Metadata Blocks
#
#########################################################################
test "metadata blocks" do
content = "a\n\n<!-- ---\ntags: [foo, bar]\n-->\n\nb"
output = "<p>a</p>\n\n<p>b</p>"
result = {'tags'=>['foo','bar']}
index = @wiki.repo.index
index.add("Bilbo-Baggins.md", content)
index.commit("Add metadata")
page = @wiki.page("Bilbo Baggins")
rendered = Gollum::Markup.new(page).render
assert_equal output, rendered
assert_equal result, page.meta_data
end
test "metadata blocks with newline" do
content = "a\n\n<!--\n---\ntags: [foo, bar]\n-->\n\nb"
output = "<p>a</p>\n\n<p>b</p>"
result = {'tags'=>['foo','bar']}
index = @wiki.repo.index
index.add("Bilbo-Baggins.md", content)
index.commit("Add metadata")
page = @wiki.page("Bilbo Baggins")
rendered = Gollum::Markup.new(page).render
assert_equal output, rendered
assert_equal result, page.meta_data
end
test "metadata sanitation" do
content = "a\n\n<!-- ---\nfoo: <script>alert('');</script>\n-->\n\nb"
output = "<p>a</p>\n\n<p>b</p>"
result = {'foo'=>nil}
index = @wiki.repo.index
index.add("Bilbo-Baggins.md", content)
index.commit("Add metadata")
page = @wiki.page("Bilbo Baggins")
rendered = Gollum::Markup.new(page).render
assert_equal output, rendered
assert_equal result, page.meta_data
end
#########################################################################
#
# Various