gollum-site 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -59,12 +59,79 @@ generation with the following data made available to it:
59
59
  * `page.author` The author of the last edit
60
60
  * `page.date` The date of the last edit
61
61
 
62
+ **A note about wiki.base_path**
63
+
64
+ *tl;dr* - Don't use "." or "" as base paths. Use "./" if relative paths are required.
65
+
66
+ The application of base path differs between Gollum page links and the layout.
67
+ Gollum uses `File.join` to combine the base path and the page link. The layout simply
68
+ renders the base path provided by the user. This can result in differing URLs.
69
+
70
+ Scenario 1: Don't include a forward slash after wiki.base_path in layouts
71
+
72
+ <table border="1" cellspacing="0" cellpadding="10">
73
+ <thead>
74
+ <tr>
75
+ <th>base_path</th>
76
+ <th>Gollum Link</th>
77
+ <th>URL</th>
78
+ <th>Layout Link</th>
79
+ <th>URL</th>
80
+ </tr>
81
+ </thead>
82
+ <tbody>
83
+ <tr>
84
+ <td>"."</td>
85
+ <td>[[Page]]</td>
86
+ <td>"./Page"</td>
87
+ <td>"{{ wiki.base_path }}Page"</td>
88
+ <td>".Page"</td>
89
+ </tr>
90
+ <tr>
91
+ <td>""</td>
92
+ <td>[[Page]]</td>
93
+ <td>"/Page"</td>
94
+ <td>"{{ wiki.base_path }}Page"</td>
95
+ <td>"Page"</td>
96
+ </tr>
97
+ </tbody>
98
+ </table>
99
+
100
+ Scenario 2: Include a forward slash after wiki.base_path in layouts
101
+
102
+
103
+ <table border="1" cellspacing="0" cellpadding="10">
104
+ <thead>
105
+ <tr>
106
+ <th>base_path</th>
107
+ <th>Gollum Link</th>
108
+ <th>URL</th>
109
+ <th>Layout Link</th>
110
+ <th>URL</th>
111
+ </tr>
112
+ </thead>
113
+ <tbody>
114
+ <tr>
115
+ <td>"/"</td>
116
+ <td>[[Page]]</td>
117
+ <td>"/Page"</td>
118
+ <td>"{{ wiki.base_path }}/Page"</td>
119
+ <td>"//Page"</td>
120
+ </tr>
121
+ </tbody>
122
+ </table>
123
+
124
+ Considering scenario 2 breaks links when using the default base path it is advised
125
+ to use scenario 1 and not use "." and "" as base paths. Use "./" if relative paths
126
+ are required.
127
+
62
128
  ## Import
63
129
 
64
130
  The gollum-site executable provides the ability to import the default layout to
65
131
  the current wiki. The import command will copy the required "_Layout.html", css
66
132
  and javascript to the current wiki. These files must be committed to the wiki
67
- repository before the 'generate' command will recognize them.
133
+ repository before the 'generate' command will recognize them unless you use the
134
+ "--working" option.
68
135
 
69
136
  $ gollum-site import
70
137
 
data/bin/gollum-site CHANGED
@@ -22,7 +22,7 @@ Options:
22
22
  HELP
23
23
 
24
24
  options = {
25
- 'ref' => ( head = Grit::Repo.new('.').head ) ? head.name : 'master', # current branch
25
+ 'ref' => Grit::Repo.new('.').git.rev_parse({}, "HEAD"), # current HEAD
26
26
  'working' => false,
27
27
  'base_path' => '/',
28
28
  'output_path' => '_site',
@@ -97,7 +97,7 @@ when 'generate'
97
97
  start = Time.now
98
98
  site.generate()
99
99
  stop = Time.now
100
- Gollum::SiteLog.debug("Generated site in #{stop - start}(s)")
100
+ puts "Generated site in #{stop - start}(s)"
101
101
  when 'serve'
102
102
  if options['watch']
103
103
  require 'directory_watcher'
data/gollum-site.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = "gollum-site"
16
16
 
17
- s.add_dependency('gollum', '>= 1.1.0')
17
+ s.add_dependency('gollum', '>= 1.2.0')
18
18
  s.add_dependency('liquid', '>= 2.2.2')
19
19
  s.add_dependency('mixlib-log', '>= 1.1.0')
20
20
 
@@ -1,36 +1,5 @@
1
1
  module Gollum
2
- class Markup
3
- # Removing sanitization; this will be configurable after Gollum 1.1.0
4
- def render(no_follow = false)
5
- sanitize_options = no_follow ?
6
- HISTORY_SANITIZATION_OPTIONS :
7
- SANITIZATION_OPTIONS
8
- if @data.respond_to?(:force_encoding)
9
- data = @data.force_encoding('UTF-8')
10
- else
11
- data = @data
12
- end
13
- data = extract_tex(data)
14
- data = extract_code(data)
15
- data = extract_tags(data)
16
- begin
17
- data = GitHub::Markup.render(@name, data)
18
- if data.nil?
19
- raise "There was an error converting #{@name} to HTML."
20
- end
21
- rescue Object => e
22
- data = %{<p class="gollum-error">#{e.message}</p>}
23
- end
24
- data = process_tags(data)
25
- data = process_code(data)
26
- sanitize_options[:elements] << 'iframe'
27
- sanitize_options[:attributes][:all] << 'frameborder'
28
- data = Sanitize.clean(data, sanitize_options)
29
- data = process_tex(data)
30
- data.gsub!(/<p><\/p>/, '')
31
- data
32
- end
33
-
2
+ class SiteMarkup < Gollum::Markup
34
3
  # Attempt to process the tag as a page link tag.
35
4
  #
36
5
  # tag - The String tag contents (the stuff inside the double
@@ -10,9 +10,7 @@ module Gollum
10
10
 
11
11
  def initialize(path, options = {})
12
12
  @wiki = Gollum::Wiki.new(path, {
13
- # markup_class should work after v1.1.0 of Gollum
14
- # need to change class name in markup.rb
15
- #:markup_class => Gollum::SiteMarkup,
13
+ :markup_class => Gollum::SiteMarkup,
16
14
  :page_class => Gollum::SitePage,
17
15
  :base_path => options[:base_path],
18
16
  :sanitization => false,
@@ -81,7 +79,7 @@ module Gollum
81
79
  deleted = @wiki.repo.git.native(:ls_files, ls_opts_del).split("\0")
82
80
  working = @wiki.repo.git.native(:ls_files, ls_opts).split("\0")
83
81
  work_tree = (working - deleted).map do |path|
84
- path = @wiki.decode_git_path(path)
82
+ path = decode_git_path(path)
85
83
  OpenStruct.new(:path => path, :data => IO.read(path))
86
84
  end
87
85
  Dir.chdir(cwd) # change back to original directory
@@ -144,5 +142,19 @@ module Gollum
144
142
  def to_liquid
145
143
  { "pages" => @pages }
146
144
  end
145
+
146
+ # Decode octal sequences (\NNN) in tree path names.
147
+ #
148
+ # path - String path name.
149
+ #
150
+ # Returns a decoded String.
151
+ def decode_git_path(path)
152
+ if path[0] == ?" && path[-1] == ?"
153
+ path = path[1...-1]
154
+ path.gsub!(/\\\d{3}/) { |m| m[1..-1].to_i(8).chr }
155
+ end
156
+ path.gsub!(/\\[rn"\\]/) { |m| eval(%("#{m.to_s}")) }
157
+ path
158
+ end
147
159
  end
148
160
  end
@@ -1,5 +1,5 @@
1
1
  module Gollum
2
2
  class Site
3
- VERSION = "0.1.7"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  end
data/lib/gollum-site.rb CHANGED
@@ -7,7 +7,6 @@ require 'gollum-site/page'
7
7
 
8
8
  # Markup does not use page version :(
9
9
  # Markup does not handle anchor tags for absent pages
10
- # Use custom Markup class once Gollum supports it (>v1.1.0)
11
10
  require 'gollum-site/markup'
12
11
 
13
12
  # Absolutely awful hack
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 7
9
- version: 0.1.7
8
+ - 8
9
+ version: 0.1.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Reverri
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-28 00:00:00 -08:00
17
+ date: 2011-03-31 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -27,9 +27,9 @@ dependencies:
27
27
  - !ruby/object:Gem::Version
28
28
  segments:
29
29
  - 1
30
- - 1
30
+ - 2
31
31
  - 0
32
- version: 1.1.0
32
+ version: 1.2.0
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency