gollum 1.2.1 → 1.3.0

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/HISTORY.md CHANGED
@@ -1,4 +1,21 @@
1
- # HEAD
1
+ # 1.3.0 / 2011-04-25
2
+
3
+ * Major Enhancements
4
+ * Listing of all Pages
5
+ * Support for running Gollum under a separate branch.
6
+ * Minor Enhancements
7
+ * Fix a security issue with rendering Mathjax.
8
+
9
+ # 1.2.0 / 2011-03-11
10
+
11
+ * Major Enhancements
12
+ * Major HTML/CSS/JS overhaul.
13
+ * Add Sidebars (similar to Footers).
14
+ * Add commit reverts.
15
+ * Minor Enhancements
16
+ * Optimization in source code highlighting, resulting in a huge
17
+ decrease in rendering time.
18
+ * Security fixes related to source code highlighting.
2
19
 
3
20
  * Major Enhancements
4
21
  * Add Page sidebars, similar to Page footers.
@@ -51,4 +68,4 @@
51
68
 
52
69
  # 1.0.0 / 2010-08-12
53
70
 
54
- * Open Source Birthday!
71
+ * Open Source Birthday!
data/bin/gollum CHANGED
@@ -48,6 +48,10 @@ opts = OptionParser.new do |opts|
48
48
  opts.on("--page-file-dir [PATH]", "Specify the sub directory for all page files (default: repository root).") do |path|
49
49
  wiki_options[:page_file_dir] = path
50
50
  end
51
+
52
+ opts.on("--ref [REF]", "Specify the repository ref to use (default: master).") do |ref|
53
+ wiki_options[:ref] = ref
54
+ end
51
55
  end
52
56
 
53
57
  # Read command line options into `options` hash
@@ -4,7 +4,7 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.5'
5
5
 
6
6
  s.name = 'gollum'
7
- s.version = '1.2.1'
7
+ s.version = '1.3.0'
8
8
  s.date = '2011-04-25'
9
9
  s.rubyforge_project = 'gollum'
10
10
 
@@ -697,6 +697,7 @@ Gem::Specification.new do |s|
697
697
  lib/gollum/frontend/templates/history.mustache
698
698
  lib/gollum/frontend/templates/layout.mustache
699
699
  lib/gollum/frontend/templates/page.mustache
700
+ lib/gollum/frontend/templates/pages.mustache
700
701
  lib/gollum/frontend/templates/search.mustache
701
702
  lib/gollum/frontend/templates/searchbar.mustache
702
703
  lib/gollum/frontend/views/compare.rb
@@ -707,6 +708,7 @@ Gem::Specification.new do |s|
707
708
  lib/gollum/frontend/views/history.rb
708
709
  lib/gollum/frontend/views/layout.rb
709
710
  lib/gollum/frontend/views/page.rb
711
+ lib/gollum/frontend/views/pages.rb
710
712
  lib/gollum/frontend/views/search.rb
711
713
  lib/gollum/git_access.rb
712
714
  lib/gollum/markup.rb
@@ -20,7 +20,7 @@ require 'gollum/albino'
20
20
  require 'gollum/sanitization'
21
21
 
22
22
  module Gollum
23
- VERSION = '1.2.1'
23
+ VERSION = '1.3.0'
24
24
 
25
25
  class Error < StandardError; end
26
26
 
@@ -62,7 +62,7 @@ module Gollum
62
62
  # Returns an array of Grit::Commit instances.
63
63
  def parents
64
64
  @parents ||= begin
65
- arr = [@options[:parent] || @wiki.repo.commit('master')]
65
+ arr = [@options[:parent] || @wiki.repo.commit(@wiki.ref)]
66
66
  arr.flatten!
67
67
  arr.compact!
68
68
  arr
@@ -142,7 +142,7 @@ module Gollum
142
142
  #
143
143
  # Returns the String SHA1 of the new commit.
144
144
  def commit
145
- sha1 = index.commit(@options[:message], parents, actor)
145
+ sha1 = index.commit(@options[:message], parents, actor, nil, @wiki.ref)
146
146
  @callbacks.each do |cb|
147
147
  cb.call(self, sha1)
148
148
  end
@@ -214,4 +214,4 @@ module Gollum
214
214
  index.send(name, *args)
215
215
  end
216
216
  end
217
- end
217
+ end
@@ -169,6 +169,13 @@ module Precious
169
169
  mustache :search
170
170
  end
171
171
 
172
+ get '/pages' do
173
+ wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
174
+ @results = wiki.pages
175
+ @ref = wiki.ref
176
+ mustache :pages
177
+ end
178
+
172
179
  get '/*' do
173
180
  show_page_or_file(params[:splat].first)
174
181
  end
@@ -42,7 +42,6 @@ a:hover, a:visited {
42
42
  line-height: normal;
43
43
  margin: 0;
44
44
  padding: 0.08em 0 0 0;
45
- width: 50%;
46
45
  }
47
46
 
48
47
  #head ul.actions {
@@ -2,6 +2,8 @@
2
2
  <div id="head">
3
3
  <h1>{{title}}</h1>
4
4
  <ul class="actions">
5
+ <li class="minibutton"><a href="/pages"
6
+ class="action-all-pages">All Pages</a></li>
5
7
  <li class="minibutton" class="jaws">
6
8
  <a href="#" id="minibutton-new-page">New Page</a></li>
7
9
  <li class="minibutton"><a href="/edit/{{escaped_name}}"
@@ -0,0 +1,35 @@
1
+ <div id="wiki-wrapper" class="results">
2
+ <div id="head">
3
+ <h1>{{title}}</h1>
4
+ <ul class="actions">
5
+ <li class="minibutton"><a href="/"
6
+ class="action-edit-page">Home</a></li>
7
+ </ul>
8
+ {{>searchbar}}
9
+ </div>
10
+ <div id="results">
11
+
12
+ {{#has_results}}
13
+ <ul>
14
+ {{#results}}
15
+ <li>
16
+ <a href="/{{name}}">{{name}}</a>
17
+ </li>
18
+ {{/results}}
19
+ </ul>
20
+ {{/has_results}}
21
+
22
+ {{#no_results}}
23
+ <p id="no-results">
24
+ There are no pages in <strong>{{ref}}</strong>.
25
+ </p>
26
+ {{/no_results}}
27
+
28
+ </div>
29
+ <div id="footer">
30
+ <ul class="actions">
31
+ <li class="minibutton"><a href="#">Back to Top</a></li>
32
+ </ul>
33
+ </div>
34
+ </div>
35
+
@@ -0,0 +1,19 @@
1
+ module Precious
2
+ module Views
3
+ class Pages < Layout
4
+ attr_reader :results, :ref
5
+
6
+ def title
7
+ "All pages in #{@ref}"
8
+ end
9
+
10
+ def has_results
11
+ !@results.empty?
12
+ end
13
+
14
+ def no_results
15
+ @results.empty?
16
+ end
17
+ end
18
+ end
19
+ end
@@ -199,10 +199,10 @@ module Gollum
199
199
  options[:pretty] = 'raw'
200
200
  options.delete :max_count
201
201
  options.delete :skip
202
- log = @wiki.repo.git.native "log", options, "master", "--", @path
202
+ log = @wiki.repo.git.native "log", options, @wiki.ref, "--", @path
203
203
  Grit::Commit.list_from_string(@wiki.repo, log)
204
204
  else
205
- @wiki.repo.log('master', @path, log_pagination_options(options))
205
+ @wiki.repo.log(@wiki.ref, @path, log_pagination_options(options))
206
206
  end
207
207
  end
208
208
 
@@ -12,6 +12,9 @@ module Gollum
12
12
  # Sets the markup class used by all instances of this Wiki.
13
13
  attr_writer :markup_class
14
14
 
15
+ # Sets the default ref for the wiki.
16
+ attr_accessor :default_ref
17
+
15
18
  # Sets the default name for commits.
16
19
  attr_accessor :default_committer_name
17
20
 
@@ -80,6 +83,7 @@ module Gollum
80
83
  end
81
84
  end
82
85
 
86
+ self.default_ref = 'master'
83
87
  self.default_committer_name = 'Anonymous'
84
88
  self.default_committer_email = 'anon@anon.com'
85
89
 
@@ -94,6 +98,9 @@ module Gollum
94
98
  # Gets the sanitization options for older page revisions used by this Wiki.
95
99
  attr_reader :history_sanitization
96
100
 
101
+ # Gets the String ref in which all page files reside.
102
+ attr_reader :ref
103
+
97
104
  # Gets the String directory in which all page files reside.
98
105
  attr_reader :page_file_dir
99
106
 
@@ -109,6 +116,7 @@ module Gollum
109
116
  # :markup_class - The markup Class. Default: Gollum::Markup
110
117
  # :sanitization - An instance of Sanitization.
111
118
  # :page_file_dir - String the directory in which all page files reside
119
+ # :ref - String the repository ref to retrieve pages from
112
120
  #
113
121
  # Returns a fresh Gollum::Repo.
114
122
  def initialize(path, options = {})
@@ -124,6 +132,7 @@ module Gollum
124
132
  @file_class = options[:file_class] || self.class.file_class
125
133
  @markup_class = options[:markup_class] || self.class.markup_class
126
134
  @repo = @access.repo
135
+ @ref = options[:ref] || self.class.default_ref
127
136
  @sanitization = options[:sanitization] || self.class.sanitization
128
137
  @history_sanitization = options[:history_sanitization] ||
129
138
  self.class.history_sanitization
@@ -139,20 +148,20 @@ module Gollum
139
148
  # Public: Get the formatted page for a given page name.
140
149
  #
141
150
  # name - The human or canonical String page name of the wiki page.
142
- # version - The String version ID to find (default: "master").
151
+ # version - The String version ID to find (default: @ref).
143
152
  #
144
153
  # Returns a Gollum::Page or nil if no matching page was found.
145
- def page(name, version = 'master')
154
+ def page(name, version = @ref)
146
155
  @page_class.new(self).find(name, version)
147
156
  end
148
157
 
149
158
  # Public: Get the static file for a given name.
150
159
  #
151
160
  # name - The full String pathname to the file.
152
- # version - The String version ID to find (default: "master").
161
+ # version - The String version ID to find (default: @ref).
153
162
  #
154
163
  # Returns a Gollum::File or nil if no matching file was found.
155
- def file(name, version = 'master')
164
+ def file(name, version = @ref)
156
165
  @file_class.new(self).find(name, version)
157
166
  end
158
167
 
@@ -290,7 +299,7 @@ module Gollum
290
299
  else
291
300
  Committer.new(self, commit)
292
301
  end
293
-
302
+
294
303
  committer.delete(page.path)
295
304
 
296
305
  committer.after_commit do |index, sha|
@@ -381,11 +390,11 @@ module Gollum
381
390
 
382
391
  # Public: Lists all pages for this wiki.
383
392
  #
384
- # treeish - The String commit ID or ref to find (default: master)
393
+ # treeish - The String commit ID or ref to find (default: @ref)
385
394
  #
386
395
  # Returns an Array of Gollum::Page instances.
387
396
  def pages(treeish = nil)
388
- tree_list(treeish || 'master')
397
+ tree_list(treeish || @ref)
389
398
  end
390
399
 
391
400
  # Public: Returns the number of pages accessible from a commit
@@ -394,7 +403,7 @@ module Gollum
394
403
  #
395
404
  # Returns a Fixnum
396
405
  def size(ref = nil)
397
- tree_map_for(ref || 'master').inject(0) do |num, entry|
406
+ tree_map_for(ref || @ref).inject(0) do |num, entry|
398
407
  num + (@page_class.valid_page_name?(entry.name) ? 1 : 0)
399
408
  end
400
409
  rescue Grit::GitRuby::Repository::NoSuchShaFound
@@ -407,7 +416,7 @@ module Gollum
407
416
  #
408
417
  # Returns an Array with Objects of page name and count of matches
409
418
  def search(query)
410
- args = [{}, '-i', '-c', query, 'master', '--']
419
+ args = [{}, '-i', '-c', query, @ref, '--']
411
420
  args << '--' << @page_file_dir if @page_file_dir
412
421
 
413
422
  @repo.git.grep(*args).split("\n").map! do |line|
@@ -429,7 +438,7 @@ module Gollum
429
438
  #
430
439
  # Returns an Array of Grit::Commit.
431
440
  def log(options = {})
432
- @repo.log('master', nil, log_pagination_options(options))
441
+ @repo.log(@ref, nil, log_pagination_options(options))
433
442
  end
434
443
 
435
444
  # Public: Refreshes just the cached Git reference data. This should
@@ -48,4 +48,17 @@ context "Wiki" do
48
48
  FileUtils.rm_rf(@path)
49
49
  end
50
50
  end
51
+
52
+ test "parents with default master ref" do
53
+ ref = 'a8ad3c09dd842a3517085bfadd37718856dee813'
54
+ committer = Gollum::Committer.new(@wiki)
55
+ assert_equal ref, committer.parents.first.sha
56
+ end
57
+
58
+ test "parents with custom ref" do
59
+ ref = '60f12f4254f58801b9ee7db7bca5fa8aeefaa56b'
60
+ @wiki = Gollum::Wiki.new(testpath("examples/lotr.git"), :ref => ref)
61
+ committer = Gollum::Committer.new(@wiki)
62
+ assert_equal ref, committer.parents.first.sha
63
+ end
51
64
  end
@@ -301,3 +301,38 @@ context "page_file_dir option" do
301
301
  FileUtils.rm_r(@path)
302
302
  end
303
303
  end
304
+
305
+ context "Wiki page writing with different branch" do
306
+ setup do
307
+ @path = testpath("examples/test.git")
308
+ FileUtils.rm_rf(@path)
309
+ @repo = Grit::Repo.init_bare(@path)
310
+ @wiki = Gollum::Wiki.new(@path)
311
+
312
+ # We need an initial commit to create the master branch
313
+ # before we can create new branches
314
+ cd = commit_details
315
+ @wiki.write_page("Gollum", :markdown, "# Gollum", cd)
316
+
317
+ # Create our test branch and check it out
318
+ @repo.update_ref("test", @repo.commits.first.id)
319
+ @branch = Gollum::Wiki.new(@path, :ref => "test")
320
+ end
321
+
322
+ teardown do
323
+ FileUtils.rm_rf(@path)
324
+ end
325
+
326
+ test "write_page" do
327
+ cd = commit_details
328
+
329
+ @branch.write_page("Bilbo", :markdown, "# Bilbo", commit_details)
330
+ assert @branch.page("Bilbo")
331
+ assert @wiki.page("Gollum")
332
+
333
+ assert_equal 1, @wiki.repo.commits.size
334
+ assert_equal 1, @branch.repo.commits.size
335
+
336
+ assert_equal nil, @wiki.page("Bilbo")
337
+ end
338
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gollum
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 2
9
- - 1
10
- version: 1.2.1
8
+ - 3
9
+ - 0
10
+ version: 1.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tom Preston-Werner
@@ -909,6 +909,7 @@ files:
909
909
  - lib/gollum/frontend/templates/history.mustache
910
910
  - lib/gollum/frontend/templates/layout.mustache
911
911
  - lib/gollum/frontend/templates/page.mustache
912
+ - lib/gollum/frontend/templates/pages.mustache
912
913
  - lib/gollum/frontend/templates/search.mustache
913
914
  - lib/gollum/frontend/templates/searchbar.mustache
914
915
  - lib/gollum/frontend/views/compare.rb
@@ -919,6 +920,7 @@ files:
919
920
  - lib/gollum/frontend/views/history.rb
920
921
  - lib/gollum/frontend/views/layout.rb
921
922
  - lib/gollum/frontend/views/page.rb
923
+ - lib/gollum/frontend/views/pages.rb
922
924
  - lib/gollum/frontend/views/search.rb
923
925
  - lib/gollum/git_access.rb
924
926
  - lib/gollum/markup.rb