gollum 2.1.0 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of gollum might be problematic. Click here for more details.
- data/gollum.gemspec +3 -3
- data/lib/gollum.rb +1 -1
- data/lib/gollum/frontend/app.rb +14 -10
- data/lib/gollum/frontend/public/gollum/javascript/editor/gollum.editor.js +2 -2
- data/lib/gollum/frontend/public/gollum/javascript/gollum.js +1 -1
- data/lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js +3 -1
- data/lib/gollum/frontend/views/page.rb +11 -0
- data/lib/gollum/markup.rb +28 -1
- data/lib/gollum/page.rb +8 -0
- data/test/test_app.rb +17 -0
- data/test/test_markup.rb +51 -0
- metadata +4 -4
data/gollum.gemspec
CHANGED
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
|
5
5
|
s.required_ruby_version = ">= 1.8.7"
|
6
6
|
|
7
7
|
s.name = 'gollum'
|
8
|
-
s.version = '2.1.
|
9
|
-
s.date = '2012-08-
|
8
|
+
s.version = '2.1.2'
|
9
|
+
s.date = '2012-08-06'
|
10
10
|
s.rubyforge_project = 'gollum'
|
11
11
|
|
12
12
|
s.summary = "A simple, Git-powered wiki."
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
|
38
38
|
s.add_development_dependency('RedCloth')
|
39
39
|
s.add_development_dependency('mocha')
|
40
|
-
s.add_development_dependency('org-ruby', '~>0.
|
40
|
+
s.add_development_dependency('org-ruby', '~> 0.7.0')
|
41
41
|
s.add_development_dependency('shoulda')
|
42
42
|
s.add_development_dependency('rack-test')
|
43
43
|
s.add_development_dependency('wikicloth', '~>0.8.0')
|
data/lib/gollum.rb
CHANGED
@@ -22,7 +22,7 @@ require File.expand_path('../gollum/tex', __FILE__)
|
|
22
22
|
require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
|
23
23
|
|
24
24
|
module Gollum
|
25
|
-
VERSION = '2.1.
|
25
|
+
VERSION = '2.1.2'
|
26
26
|
|
27
27
|
def self.assets_path
|
28
28
|
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
|
data/lib/gollum/frontend/app.rb
CHANGED
@@ -82,7 +82,7 @@ module Precious
|
|
82
82
|
end
|
83
83
|
|
84
84
|
before do
|
85
|
-
@base_url =
|
85
|
+
@base_url = url('/', false)
|
86
86
|
settings.wiki_options.merge!({ :base_path => @base_url }) unless settings.wiki_options.has_key? :base_path
|
87
87
|
end
|
88
88
|
|
@@ -90,12 +90,16 @@ module Precious
|
|
90
90
|
show_page_or_file('Home')
|
91
91
|
end
|
92
92
|
|
93
|
+
# path is set to name if path is nil.
|
94
|
+
# if path is 'a/b' and a and b are dirs, then
|
95
|
+
# path must have a trailing slash 'a/b/' or
|
96
|
+
# extract_path will trim path to 'a'
|
93
97
|
# name, path, version
|
94
98
|
def wiki_page( name, path = nil, version = nil)
|
95
99
|
path = name if path.nil?
|
96
|
-
|
97
100
|
name = extract_name(name)
|
98
101
|
path = extract_path(path)
|
102
|
+
|
99
103
|
wiki = wiki_new
|
100
104
|
|
101
105
|
OpenStruct.new(:wiki => wiki, :page => wiki.paged(name, path, version),
|
@@ -137,7 +141,7 @@ module Precious
|
|
137
141
|
end
|
138
142
|
|
139
143
|
post '/edit/*' do
|
140
|
-
wikip
|
144
|
+
wikip = wiki_page(CGI.unescape(params[:page]), sanitize_empty_params(params[:path]))
|
141
145
|
path = wikip.path
|
142
146
|
wiki = wikip.wiki
|
143
147
|
page = wikip.page
|
@@ -168,9 +172,8 @@ module Precious
|
|
168
172
|
end
|
169
173
|
|
170
174
|
get '/create/*' do
|
171
|
-
|
172
|
-
|
173
|
-
@name = wikip.name
|
175
|
+
wikip = wiki_page(params[:splat].first)
|
176
|
+
@name = wikip.name.to_url
|
174
177
|
@path = wikip.path
|
175
178
|
|
176
179
|
page = wikip.page
|
@@ -193,7 +196,7 @@ module Precious
|
|
193
196
|
begin
|
194
197
|
wiki.write_page(name, format, params[:content], commit_message)
|
195
198
|
page = wiki.page(name)
|
196
|
-
redirect to("/#{page.escaped_url_path}")
|
199
|
+
redirect to("/#{page.escaped_url_path}") unless page.nil?
|
197
200
|
rescue Gollum::DuplicatePageError => e
|
198
201
|
@message = "Duplicate page: #{e.message}"
|
199
202
|
mustache :error
|
@@ -285,10 +288,11 @@ module Precious
|
|
285
288
|
|
286
289
|
get %r{/(.+?)/([0-9a-f]{40})} do
|
287
290
|
file_path = params[:captures][0]
|
288
|
-
name = extract_name(file_path)
|
289
|
-
path = extract_path(file_path)
|
290
291
|
version = params[:captures][1]
|
291
|
-
|
292
|
+
wikip = wiki_page(file_path, file_path, version)
|
293
|
+
name = wikip.name
|
294
|
+
path = wikip.path
|
295
|
+
if page = wikip.page
|
292
296
|
@page = page
|
293
297
|
@name = name
|
294
298
|
@content = page.formatted_data
|
@@ -167,7 +167,7 @@
|
|
167
167
|
|
168
168
|
setActiveLanguage: function( name ) {
|
169
169
|
// On first load _ACTIVE_LANG.length is 0 and evtChangeFormat isn't called.
|
170
|
-
if ( LanguageDefinition._ACTIVE_LANG.length <= 0 ) {
|
170
|
+
if ( LanguageDefinition._ACTIVE_LANG != null && LanguageDefinition._ACTIVE_LANG.length <= 0 ) {
|
171
171
|
FormatSelector.updateCommitMessage( name );
|
172
172
|
}
|
173
173
|
|
@@ -277,7 +277,7 @@
|
|
277
277
|
}
|
278
278
|
|
279
279
|
// attempt to load the definition for this language
|
280
|
-
var script_uri = baseUrl + '/javascript/editor/langs/' + markup_name + '.js';
|
280
|
+
var script_uri = '.' + baseUrl + '/javascript/editor/langs/' + markup_name + '.js';
|
281
281
|
$.ajax({
|
282
282
|
url: script_uri,
|
283
283
|
dataType: 'script',
|
@@ -157,7 +157,7 @@ $(document).ready(function() {
|
|
157
157
|
var path = location.pathname;
|
158
158
|
// ensure there's more than one slash in pathname.
|
159
159
|
if (path.split('/').length > 2) {
|
160
|
-
path = path.substr(path.lastIndexOf('/')+1)
|
160
|
+
path = path.substr(0, path.lastIndexOf('/') + 1);
|
161
161
|
} else {
|
162
162
|
path = '';
|
163
163
|
}
|
@@ -99,8 +99,10 @@ $.save = function( commitMessage ) {
|
|
99
99
|
var msg = defaultCommitMessage();
|
100
100
|
var newLocation = location.protocol + '//' + location.host + baseUrl;
|
101
101
|
|
102
|
+
// 'a%2Fb' => a/b
|
102
103
|
if (pathName) {
|
103
|
-
newLocation += '/' + pathName;
|
104
|
+
newLocation += '/' + unescape(pathName);
|
105
|
+
pathName = pathName + '/'; // pathName must end with /
|
104
106
|
}
|
105
107
|
|
106
108
|
newLocation += '/' + pageName;
|
data/lib/gollum/markup.rb
CHANGED
@@ -7,6 +7,8 @@ module Gollum
|
|
7
7
|
|
8
8
|
class Markup
|
9
9
|
attr_accessor :toc
|
10
|
+
attr_reader :metadata
|
11
|
+
|
10
12
|
# Initialize a new Markup object.
|
11
13
|
#
|
12
14
|
# page - The Gollum::Page.
|
@@ -27,6 +29,7 @@ module Gollum
|
|
27
29
|
@wsdmap = {}
|
28
30
|
@premap = {}
|
29
31
|
@toc = nil
|
32
|
+
@metadata = nil
|
30
33
|
end
|
31
34
|
|
32
35
|
# Render the content with Gollum wiki syntax on top of the file's own
|
@@ -43,6 +46,7 @@ module Gollum
|
|
43
46
|
@wiki.sanitizer
|
44
47
|
|
45
48
|
data = @data.dup
|
49
|
+
data = extract_metadata(data)
|
46
50
|
data = extract_code(data)
|
47
51
|
data = extract_tex(data)
|
48
52
|
data = extract_wsd(data)
|
@@ -399,7 +403,7 @@ module Gollum
|
|
399
403
|
link_name = @wiki.page_class.cname(page.name)
|
400
404
|
presence = "present"
|
401
405
|
end
|
402
|
-
link = ::File.join(@wiki.base_path, CGI.escape(link_name))
|
406
|
+
link = ::File.join(@wiki.base_path, page ? page.escaped_url_path : CGI.escape(link_name))
|
403
407
|
%{<a class="internal #{presence}" href="#{link}#{extra}">#{name}</a>}
|
404
408
|
end
|
405
409
|
end
|
@@ -565,6 +569,29 @@ module Gollum
|
|
565
569
|
data
|
566
570
|
end
|
567
571
|
|
572
|
+
#########################################################################
|
573
|
+
#
|
574
|
+
# Metadata
|
575
|
+
#
|
576
|
+
#########################################################################
|
577
|
+
|
578
|
+
# Extract metadata for data and build metadata table. Metadata
|
579
|
+
# is content found between `<!-- ---` and `-->` markers, and must
|
580
|
+
# be a valid YAML mapping.
|
581
|
+
#
|
582
|
+
# Returns the String of formatted data with metadata removed.
|
583
|
+
def extract_metadata(data)
|
584
|
+
@metadata ||= {}
|
585
|
+
data.gsub(/\<\!--+\s+---(.*?)--+\>/m) do
|
586
|
+
yaml = @wiki.sanitizer.clean($1)
|
587
|
+
hash = YAML.load(yaml)
|
588
|
+
if Hash === hash
|
589
|
+
@metadata.update(hash)
|
590
|
+
end
|
591
|
+
''
|
592
|
+
end
|
593
|
+
end
|
594
|
+
|
568
595
|
# Hook for getting the formatted value of extracted tag data.
|
569
596
|
#
|
570
597
|
# type - Symbol value identifying what type of data is being extracted.
|
data/lib/gollum/page.rb
CHANGED
@@ -217,6 +217,14 @@ module Gollum
|
|
217
217
|
markup_class.toc
|
218
218
|
end
|
219
219
|
|
220
|
+
# Public: Embedded metadata.
|
221
|
+
#
|
222
|
+
# Returns Hash of metadata.
|
223
|
+
def meta_data()
|
224
|
+
formatted_data if markup_class.metadata == nil
|
225
|
+
markup_class.metadata
|
226
|
+
end
|
227
|
+
|
220
228
|
# Public: The format of the page.
|
221
229
|
#
|
222
230
|
# Returns the Symbol format of the page. One of:
|
data/test/test_app.rb
CHANGED
@@ -142,6 +142,23 @@ context "Frontend" do
|
|
142
142
|
assert last_response.ok?
|
143
143
|
end
|
144
144
|
|
145
|
+
test "page create and edit with dash" do
|
146
|
+
page = 'c-d-e'
|
147
|
+
path = 'a/b/' # path must end with /
|
148
|
+
|
149
|
+
post '/create', :content => 'create_msg', :page => page,
|
150
|
+
:path => path, :format => 'markdown', :message => ''
|
151
|
+
assert_equal 'create_msg', @wiki.paged(page, path).raw_data
|
152
|
+
|
153
|
+
# must clear or create_msg will be returned
|
154
|
+
@wiki.clear_cache
|
155
|
+
|
156
|
+
# post '/edit' fails. post '/edit/' works.
|
157
|
+
post '/edit/', :content => 'edit_msg',
|
158
|
+
:page => page, :path => path, :message => ''
|
159
|
+
assert_equal 'edit_msg', @wiki.paged(page, path).raw_data
|
160
|
+
end
|
161
|
+
|
145
162
|
test "guards against creation of existing page" do
|
146
163
|
name = "A"
|
147
164
|
post "/create", :content => 'abc', :page => name,
|
data/test/test_markup.rb
CHANGED
@@ -517,6 +517,57 @@ np.array([[2,2],[1,3]],np.float)
|
|
517
517
|
assert_not_nil rendered.match(output)
|
518
518
|
end
|
519
519
|
|
520
|
+
#########################################################################
|
521
|
+
#
|
522
|
+
# Metadata Blocks
|
523
|
+
#
|
524
|
+
#########################################################################
|
525
|
+
|
526
|
+
test "metadata blocks" do
|
527
|
+
content = "a\n\n<!-- ---\ntags: [foo, bar]\n-->\n\nb"
|
528
|
+
output = "<p>a</p>\n\n<p>b</p>"
|
529
|
+
result = {'tags'=>['foo','bar']}
|
530
|
+
|
531
|
+
index = @wiki.repo.index
|
532
|
+
index.add("Bilbo-Baggins.md", content)
|
533
|
+
index.commit("Add metadata")
|
534
|
+
|
535
|
+
page = @wiki.page("Bilbo Baggins")
|
536
|
+
rendered = Gollum::Markup.new(page).render
|
537
|
+
assert_equal output, rendered
|
538
|
+
assert_equal result, page.meta_data
|
539
|
+
end
|
540
|
+
|
541
|
+
test "metadata blocks with newline" do
|
542
|
+
content = "a\n\n<!--\n---\ntags: [foo, bar]\n-->\n\nb"
|
543
|
+
output = "<p>a</p>\n\n<p>b</p>"
|
544
|
+
result = {'tags'=>['foo','bar']}
|
545
|
+
|
546
|
+
index = @wiki.repo.index
|
547
|
+
index.add("Bilbo-Baggins.md", content)
|
548
|
+
index.commit("Add metadata")
|
549
|
+
|
550
|
+
page = @wiki.page("Bilbo Baggins")
|
551
|
+
rendered = Gollum::Markup.new(page).render
|
552
|
+
assert_equal output, rendered
|
553
|
+
assert_equal result, page.meta_data
|
554
|
+
end
|
555
|
+
|
556
|
+
test "metadata sanitation" do
|
557
|
+
content = "a\n\n<!-- ---\nfoo: <script>alert('');</script>\n-->\n\nb"
|
558
|
+
output = "<p>a</p>\n\n<p>b</p>"
|
559
|
+
result = {'foo'=>nil}
|
560
|
+
|
561
|
+
index = @wiki.repo.index
|
562
|
+
index.add("Bilbo-Baggins.md", content)
|
563
|
+
index.commit("Add metadata")
|
564
|
+
|
565
|
+
page = @wiki.page("Bilbo Baggins")
|
566
|
+
rendered = Gollum::Markup.new(page).render
|
567
|
+
assert_equal output, rendered
|
568
|
+
assert_equal result, page.meta_data
|
569
|
+
end
|
570
|
+
|
520
571
|
#########################################################################
|
521
572
|
#
|
522
573
|
# Various
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gollum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-08-
|
13
|
+
date: 2012-08-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: grit
|
@@ -239,7 +239,7 @@ dependencies:
|
|
239
239
|
requirements:
|
240
240
|
- - ~>
|
241
241
|
- !ruby/object:Gem::Version
|
242
|
-
version: 0.
|
242
|
+
version: 0.7.0
|
243
243
|
type: :development
|
244
244
|
prerelease: false
|
245
245
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -247,7 +247,7 @@ dependencies:
|
|
247
247
|
requirements:
|
248
248
|
- - ~>
|
249
249
|
- !ruby/object:Gem::Version
|
250
|
-
version: 0.
|
250
|
+
version: 0.7.0
|
251
251
|
- !ruby/object:Gem::Dependency
|
252
252
|
name: shoulda
|
253
253
|
requirement: !ruby/object:Gem::Requirement
|