gollum 2.3.12 → 2.4.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/README.md CHANGED
@@ -136,7 +136,13 @@ or JavaScript. These tags will be stripped from the converted HTML. See
136
136
  `docs/sanitization.md` for more details on what tags and attributes are
137
137
  allowed.
138
138
 
139
+ ## TITLES
139
140
 
141
+ The first defined `h1` will override the default header on a page. There are two ways to set a page title. The metadata syntax:
142
+
143
+ `<!-- --- title: New Title -->`
144
+
145
+ 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.
140
146
  ## BRACKET TAGS
141
147
 
142
148
  A variety of Gollum tags use a double bracket syntax. For example:
@@ -538,7 +544,7 @@ Gollum optionally takes a `--config file`. See [config.rb](https://github.com/gi
538
544
 
539
545
  ## CUSTOM CSS
540
546
 
541
- The `--css` flag will inject `custom.css` from the root of your git repository into each page. Here's an example of floating the sidebar to the left.
547
+ 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.
542
548
 
543
549
  ```css
544
550
  #wiki-rightbar { float: left !important; }
data/Rakefile CHANGED
@@ -146,7 +146,7 @@ task :gemspec => :validate do
146
146
  split("\n").
147
147
  sort.
148
148
  reject { |file| file =~ /^\./ }.
149
- reject { |file| file =~ /^(rdoc|pkg|test|Home\.md)/ }.
149
+ reject { |file| file =~ /^(rdoc|pkg|test|Home\.md|\.gitattributes)/ }.
150
150
  map { |file| " #{file}" }.
151
151
  join("\n")
152
152
 
data/bin/gollum CHANGED
@@ -80,6 +80,9 @@ opts = OptionParser.new do |opts|
80
80
  opts.on("--collapse-tree", "Collapse file view tree. By default, expanded tree is shown.") do
81
81
  wiki_options[:collapse_tree] = true
82
82
  end
83
+ opts.on("--h1-title", "Sets page title to value of first h1") do
84
+ wiki_options[:h1_title] = true
85
+ end
83
86
  end
84
87
 
85
88
  # Read command line options into `options` hash
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.3.12'
9
- s.date = '2012-11-07'
8
+ s.version = '2.4.0'
9
+ s.date = '2012-11-11'
10
10
  s.rubyforge_project = 'gollum'
11
11
 
12
12
  s.summary = "A simple, Git-powered wiki."
data/lib/gollum.rb CHANGED
@@ -23,7 +23,7 @@ require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
23
23
  require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
24
24
 
25
25
  module Gollum
26
- VERSION = '2.3.12'
26
+ VERSION = '2.4.0'
27
27
 
28
28
  def self.assets_path
29
29
  ::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
@@ -22,7 +22,7 @@ module Gollum
22
22
  def new_page page
23
23
  name = page.name
24
24
  url = url_for_page page
25
- %Q( <li class="file"><a href="#{url}">#{name}</a></li>\n)
25
+ %Q( <li class="file"><a href="#{url}"><span class="icon"></span>#{name}</a></li>)
26
26
  end
27
27
 
28
28
  def new_folder folder_path
@@ -38,10 +38,7 @@ module Gollum
38
38
  end
39
39
 
40
40
  def end_folder
41
- <<-HTML
42
- </ol>
43
- </li>
44
- HTML
41
+ "</ol></li>\n"
45
42
  end
46
43
 
47
44
  def url_for_page page
@@ -85,13 +82,11 @@ module Gollum
85
82
  # Handle special case of only one folder.
86
83
  if (count - folder_start == 1)
87
84
  page = @pages[ folder_start ]
88
- name = page.name
89
- url = url_for_page page
90
85
  html += <<-HTML
91
86
  <li>
92
87
  <label>#{::File.dirname(page.path)}</label> <input type="checkbox" #{@checked} />
93
88
  <ol>
94
- <li class="file"><a href="#{url}">#{name}</a></li>
89
+ #{new_page page}
95
90
  </ol>
96
91
  </li>
97
92
  HTML
@@ -239,6 +239,7 @@ module Precious
239
239
  @toc_content = wiki.universal_toc ? @page.toc_data : nil
240
240
  @mathjax = wiki.mathjax
241
241
  @css = wiki.css
242
+ @h1_title = wiki.h1_title
242
243
  @editable = false
243
244
  mustache :page
244
245
  end
@@ -362,6 +363,7 @@ module Precious
362
363
  @toc_content = wiki.universal_toc ? @page.toc_data : nil
363
364
  @mathjax = wiki.mathjax
364
365
  @css = wiki.css
366
+ @h1_title = wiki.h1_title
365
367
  mustache :page
366
368
  elsif file = wiki.file(fullpath)
367
369
  content_type file.mime_type
@@ -1,121 +1,128 @@
1
- *, html {
2
- font-family: Verdana, Arial, Helvetica, sans-serif;
3
- }
4
-
5
- #results a:hover {
6
- background-color: #4c4c4c;
7
- }
8
-
9
- #home_button {
10
- position: absolute;
11
- top: 10px;
12
- left: 50%;
13
- }
14
-
15
- #home_button .minibutton {
16
- font-size: 1em;
17
- text-align: center;
18
- }
19
-
20
- #results {
21
- position: absolute;
22
- top: 60px;
23
- left: 10px;
24
- }
25
-
26
- body, form, ul, li, p, h1, h2, h3, h4, h5 {
27
- margin: 0;
28
- padding: 0;
29
- }
30
-
31
- body {
32
- background-color: #606061;
33
- color: #ffffff;
34
- margin: 0;
35
- }
36
-
37
- img {
38
- border: none;
39
- }
40
-
41
- p {
42
- font-size: 1em;
43
- margin: 0 0 1em 0;
44
- }
45
-
46
- html { font-size: 100%; /* IE hack */ }
47
- body { font-size: 1em; /* Sets base font size to 16px */ }
48
- table { font-size: 100%; /* IE hack */ }
49
- input, select, textarea, th, td { font-size: 1em; }
50
-
51
- /* Prevent wrapping on large file names. */
52
- li.file {
53
- white-space: nowrap;
54
- }
55
-
56
- /* CSS Tree menu styles */
57
- ol.tree
58
- {
59
- padding: 0 0 0 30px;
60
- width: 300px;
61
- }
62
- li
63
- {
64
- position: relative;
65
- margin-left: -15px;
66
- list-style: none;
67
- }
68
- li.file
69
- {
70
- margin-left: -1px !important;
71
- height: 1.5em;
72
- }
73
- li.file a
74
- {
75
- background: url(../images/fileview/document.png) 0 0 no-repeat;
76
- color: #fff;
77
- padding-left: 21px;
78
- text-decoration: none;
79
- display: block;
80
- }
81
- li.file a[href *= '.pdf'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
82
- li.file a[href *= '.html'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
83
- li.file a[href $= '.css'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
84
- li.file a[href $= '.js'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
85
- li input
86
- {
87
- position: absolute;
88
- left: 0;
89
- margin-left: 0;
90
- opacity: 0;
91
- z-index: 2;
92
- cursor: pointer;
93
- height: 1em;
94
- width: 1em;
95
- top: 0;
96
- }
97
- li input + ol
98
- {
99
- background: url(../images/fileview/toggle-small-expand.png) 40px 0 no-repeat;
100
- margin: -1.188em 0 0 -44px; /* 15px */
101
- height: 1.5em;
102
- }
103
- li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; }
104
- li label
105
- {
106
- background: url(../images/fileview/folder-horizontal.png) 15px 1px no-repeat;
107
- cursor: pointer;
108
- display: block;
109
- padding-left: 37px;
110
- }
111
-
112
- li input:checked + ol
113
- {
114
- background: url(../images/fileview/toggle-small.png) 40px 5px no-repeat;
115
- margin: -1.5em 0 0 -44px; /* 20px */
116
- padding: 1.563em 0 0 80px;
117
- height: auto;
118
- }
119
- li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */}
120
- li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ }
121
-
1
+ *, html {
2
+ font-family: Verdana, Arial, Helvetica, sans-serif;
3
+ }
4
+
5
+ #results a:hover {
6
+ background-color: #4c4c4c;
7
+ }
8
+
9
+ #home_button {
10
+ position: absolute;
11
+ top: 10px;
12
+ left: 50%;
13
+ }
14
+
15
+ #home_button .minibutton {
16
+ font-size: 1em;
17
+ text-align: center;
18
+ }
19
+
20
+ #results {
21
+ position: absolute;
22
+ top: 60px;
23
+ left: 10px;
24
+ }
25
+
26
+ body, form, ul, li, p, h1, h2, h3, h4, h5 {
27
+ margin: 0;
28
+ padding: 0;
29
+ }
30
+
31
+ body {
32
+ background-color: #606061;
33
+ color: #ffffff;
34
+ margin: 0;
35
+ }
36
+
37
+ img {
38
+ border: none;
39
+ }
40
+
41
+ p {
42
+ font-size: 1em;
43
+ margin: 0 0 1em 0;
44
+ }
45
+
46
+ html { font-size: 100%; /* IE hack */ }
47
+ body { font-size: 1em; /* Sets base font size to 16px */ }
48
+ table { font-size: 100%; /* IE hack */ }
49
+ input, select, textarea, th, td { font-size: 1em; }
50
+
51
+ /* Prevent wrapping on large file names. */
52
+ li.file {
53
+ white-space: nowrap;
54
+ }
55
+
56
+ /* CSS Tree menu styles */
57
+ ol.tree
58
+ {
59
+ padding: 0 0 0 30px;
60
+ width: 300px;
61
+ }
62
+ li
63
+ {
64
+ position: relative;
65
+ margin-left: -15px;
66
+ list-style: none;
67
+ }
68
+ li.file
69
+ {
70
+ margin-left: -1px !important;
71
+ height: 1.5em;
72
+ }
73
+ li.file a
74
+ {
75
+ color: #fff;
76
+ text-decoration: none;
77
+ display: inline-block;
78
+ }
79
+ li.file a span.icon
80
+ {
81
+ width: 14px;
82
+ height: 18px;
83
+ background: url(../images/fileview/document.png) 0 0 no-repeat;
84
+ display: inline-block;
85
+ margin-right: 7px;
86
+ vertical-align: text-top;
87
+ }
88
+ li.file a[href *= '.pdf'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
89
+ li.file a[href *= '.html'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
90
+ li.file a[href $= '.css'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
91
+ li.file a[href $= '.js'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
92
+ li input
93
+ {
94
+ position: absolute;
95
+ left: 0;
96
+ margin-left: 0;
97
+ opacity: 0;
98
+ z-index: 2;
99
+ cursor: pointer;
100
+ height: 1em;
101
+ width: 1em;
102
+ top: 0;
103
+ }
104
+ li input + ol
105
+ {
106
+ background: url(../images/fileview/toggle-small-expand.png) 40px 0 no-repeat;
107
+ margin: -1.188em 0 0 -44px; /* 15px */
108
+ height: 1.5em;
109
+ }
110
+ li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; }
111
+ li label
112
+ {
113
+ background: url(../images/fileview/folder-horizontal.png) 15px 1px no-repeat;
114
+ cursor: pointer;
115
+ display: block;
116
+ padding-left: 37px;
117
+ }
118
+
119
+ li input:checked + ol
120
+ {
121
+ background: url(../images/fileview/toggle-small.png) 40px 5px no-repeat;
122
+ margin: -1.5em 0 0 -44px; /* 20px */
123
+ padding: 1.563em 0 0 80px;
124
+ height: auto;
125
+ }
126
+ li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */}
127
+ li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ }
128
+
@@ -7,7 +7,7 @@ Mousetrap.bind(['e'], function( e ) {
7
7
  </script>
8
8
  <div id="wiki-wrapper" class="page">
9
9
  <div id="head">
10
- <h1>{{title}}</h1>
10
+ <h1>{{page_header}}</h1>
11
11
  <ul class="actions">
12
12
  <li class="minibutton">
13
13
  {{>searchbar}}
@@ -8,7 +8,16 @@ module Precious
8
8
  DEFAULT_AUTHOR = 'you'
9
9
 
10
10
  def title
11
- @page.url_path.gsub("-", " ")
11
+ h1 = @h1_title ? page_header_from_content(@content) : false
12
+ h1 || @page.url_path_title
13
+ end
14
+
15
+ def page_header
16
+ page_header_from_content(@content) || title
17
+ end
18
+
19
+ def content
20
+ content_without_page_header(@content)
12
21
  end
13
22
 
14
23
  def author
@@ -94,6 +103,48 @@ module Precious
94
103
  def metadata
95
104
  @page.metadata
96
105
  end
106
+
107
+ private
108
+
109
+ # Wraps page formatted data to Nokogiri::HTML document.
110
+ #
111
+ def build_document(content)
112
+ Nokogiri::HTML(%{<div id="gollum-root">} + content + %{</div>})
113
+ end
114
+
115
+ # Finds header node inside Nokogiri::HTML document.
116
+ #
117
+ def find_header_node(doc)
118
+ case self.format
119
+ when :asciidoc
120
+ doc.css("div#gollum-root > div#header > h1:first-child")
121
+ when :org
122
+ doc.css("div#gollum-root > p.title:first-child")
123
+ when :pod
124
+ doc.css("div#gollum-root > a.dummyTopAnchor:first-child + h1")
125
+ when :rest
126
+ doc.css("div#gollum-root > div > div > h1:first-child")
127
+ else
128
+ doc.css("div#gollum-root > h1:first-child")
129
+ end
130
+ end
131
+
132
+ # Extracts title from page if present.
133
+ #
134
+ def page_header_from_content(content)
135
+ doc = build_document(content)
136
+ title = find_header_node(doc)
137
+ Sanitize.clean(title.to_html).strip unless title.empty?
138
+ end
139
+
140
+ # Returns page content without title if it was extracted.
141
+ #
142
+ def content_without_page_header(content)
143
+ doc = build_document(content)
144
+ title = find_header_node(doc)
145
+ title.remove unless title.empty?
146
+ doc.css("div#gollum-root").inner_html
147
+ end
97
148
  end
98
149
  end
99
150
  end
data/lib/gollum/page.rb CHANGED
@@ -168,6 +168,27 @@ module Gollum
168
168
  path
169
169
  end
170
170
 
171
+ # Public: Defines title for page.rb
172
+ #
173
+ # Returns the String title
174
+ def url_path_title
175
+ metadata_title || url_path.gsub("-", " ")
176
+ end
177
+
178
+ # Public: Metadata title
179
+ #
180
+ # Set with <!-- --- title: New Title --> in page content
181
+ #
182
+ # Returns the String title or nil if not defined
183
+ def metadata_title
184
+ if metadata
185
+ title = metadata['title']
186
+ return title unless title.nil?
187
+ end
188
+
189
+ nil
190
+ end
191
+
171
192
  # Public: The url_path, but CGI escaped.
172
193
  #
173
194
  # Returns the String url_path
@@ -221,7 +242,7 @@ module Gollum
221
242
  # Public: Embedded metadata.
222
243
  #
223
244
  # Returns Hash of metadata.
224
- def meta_data()
245
+ def metadata()
225
246
  formatted_data if markup_class.metadata == nil
226
247
  markup_class.metadata
227
248
  end
data/lib/gollum/wiki.rb CHANGED
@@ -141,6 +141,10 @@ module Gollum
141
141
  # Defaults to false
142
142
  attr_reader :css
143
143
 
144
+ # Sets page title to value of first h1
145
+ # Defaults to false
146
+ attr_reader :h1_title
147
+
144
148
  # Public: Initialize a new Gollum Repo.
145
149
  #
146
150
  # path - The String path to the Git repository that holds the Gollum
@@ -196,6 +200,7 @@ module Gollum
196
200
  @show_all = options.fetch :show_all, false
197
201
  @collapse_tree = options.fetch :collapse_tree, false
198
202
  @css = options.fetch :css, false
203
+ @h1_title = options.fetch :h1_title, false
199
204
  end
200
205
 
201
206
  # Public: check whether the wiki's git repo exists on the filesystem.
@@ -1,3 +1,12 @@
1
+ For gollum code, everything should fall under the existing MIT License.
2
+ Alternative permissive licenses (such as BSD) for 3rd party dependencies are
3
+ acceptable. For image assets in Gollum, CC BY or CC BY-SA is fine. Anything
4
+ released under a copyleft license (for example GPL, AGPL, LGPL, MPL, EPL,
5
+ etc.) is not permitted in gollum. Public domain, CC BY or CC BY-SA for code in
6
+ gollum is not permitted.
7
+
8
+ ---
9
+
1
10
  The following PNGs are based on Ubuntu 11.10 SVG files located in /usr/share/icons/unity-icon-theme/places/svg/
2
11
  - group-folders.svg
3
12
  - group-files.svg
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.3.12
4
+ version: 2.4.0
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-11-07 00:00:00.000000000 Z
13
+ date: 2012-11-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: grit