gitlab-gollum-lib 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/HISTORY.md +3 -0
- data/LICENSE +21 -0
- data/README.md +601 -0
- data/Rakefile +171 -0
- data/docs/sanitization.md +33 -0
- data/gollum-lib.gemspec +75 -0
- data/lib/gollum-lib.rb +53 -0
- data/lib/gollum-lib/blob_entry.rb +95 -0
- data/lib/gollum-lib/committer.rb +236 -0
- data/lib/gollum-lib/file.rb +101 -0
- data/lib/gollum-lib/file_view.rb +155 -0
- data/lib/gollum-lib/git_access.rb +249 -0
- data/lib/gollum-lib/gitcode.rb +48 -0
- data/lib/gollum-lib/grit_ext.rb +20 -0
- data/lib/gollum-lib/helpers.rb +13 -0
- data/lib/gollum-lib/markup.rb +689 -0
- data/lib/gollum-lib/markups.rb +14 -0
- data/lib/gollum-lib/page.rb +485 -0
- data/lib/gollum-lib/pagination.rb +62 -0
- data/lib/gollum-lib/remote_code.rb +39 -0
- data/lib/gollum-lib/sanitization.rb +176 -0
- data/lib/gollum-lib/web_sequence_diagram.rb +44 -0
- data/lib/gollum-lib/wiki.rb +833 -0
- data/licenses/licenses.txt +6 -0
- metadata +315 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4d4fdef38c51a9c1ce4d12494e4feec9adda5e49
|
4
|
+
data.tar.gz: e55cb472b31d3b01cd91b953a2e0c20c9943a794
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5736f9118004578ca5fc1b180b02f6638fad6b40168daca894bce63ae6a7eb7f9b3349329027d2c40bd10bb210118d5127f8a6319458dfdd6a03465ba27dfecb
|
7
|
+
data.tar.gz: f5f5b35e228843d6c2207d0aff58d3e55b3f5a015244c55854f074e0c4de7d84c0d2902f934572571b31b840b17d7c9bcf7602bac987c4c3572e6169ba773bdd
|
data/Gemfile
ADDED
data/HISTORY.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) Tom Preston-Werner, Rick Olson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,601 @@
|
|
1
|
+
gollum lib -- A wiki built on top of Git
|
2
|
+
========================================
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/gollum/gollum-lib.png)](https://travis-ci.org/gollum/gollum-lib)
|
5
|
+
[![Dependency Status](https://gemnasium.com/gollum/gollum-lib.png)](https://gemnasium.com/gollum/gollum-lib)
|
6
|
+
|
7
|
+
## DESCRIPTION
|
8
|
+
|
9
|
+
[Gollum](https://github.com/gollum/gollum) is a simple wiki system built on
|
10
|
+
top of Git that powers GitHub Wikis.
|
11
|
+
|
12
|
+
Gollum-lib is the Ruby API that allows you to retrieve raw or formatted wiki
|
13
|
+
content from a Git repository, write new content to the repository, and collect
|
14
|
+
various meta data about the wiki as a whole.
|
15
|
+
|
16
|
+
Gollum-lib follows the rules of [Semantic Versioning](http://semver.org/) and uses
|
17
|
+
[TomDoc](http://tomdoc.org/) for inline documentation.
|
18
|
+
|
19
|
+
## SYSTEM REQUIREMENTS
|
20
|
+
|
21
|
+
- Python 2.5+ (2.7.3 recommended)
|
22
|
+
- Ruby 1.8.7+ (1.9.3 recommended)
|
23
|
+
- Unix like operating system (OS X, Ubuntu, Debian, and more)
|
24
|
+
- Will not work on Windows (because of [grit](https://github.com/github/grit))
|
25
|
+
|
26
|
+
## INSTALLATION
|
27
|
+
|
28
|
+
The best way to install Gollum-lib is with RubyGems:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
$ [sudo] gem install gollum-lib
|
32
|
+
```
|
33
|
+
|
34
|
+
If you're installing from source, you can use [Bundler][bundler] to pick up all the
|
35
|
+
gems:
|
36
|
+
|
37
|
+
```bash
|
38
|
+
$ bundle install
|
39
|
+
```
|
40
|
+
|
41
|
+
In order to use the various formats that Gollum supports, you will need to
|
42
|
+
separately install the necessary dependencies for each format. You only need
|
43
|
+
to install the dependencies for the formats that you plan to use.
|
44
|
+
|
45
|
+
* [ASCIIDoc](http://www.methods.co.nz/asciidoc/) -- `brew install asciidoc` on mac or `apt-get install -y asciidoc` on Ubuntu
|
46
|
+
* [Creole](http://wikicreole.org/) -- `gem install creole`
|
47
|
+
* [Markdown](http://daringfireball.net/projects/markdown/) -- `gem install redcarpet`
|
48
|
+
* [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) -- `gem install github-markdown`
|
49
|
+
* [Org](http://orgmode.org/) -- `gem install org-ruby`
|
50
|
+
* [Pod](http://search.cpan.org/dist/perl/pod/perlpod.pod) -- `Pod::Simple::HTML` comes with Perl >= 5.10. Lower versions should install Pod::Simple from CPAN.
|
51
|
+
* [RDoc](http://rdoc.sourceforge.net/)
|
52
|
+
* [ReStructuredText](http://docutils.sourceforge.net/rst.html) -- `easy_install docutils`
|
53
|
+
* [Textile](http://www.textism.com/tools/textile/) -- `gem install RedCloth`
|
54
|
+
* [MediaWiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `gem install wikicloth`
|
55
|
+
|
56
|
+
[bundler]: http://gembundler.com/
|
57
|
+
|
58
|
+
## PAGE FILES
|
59
|
+
|
60
|
+
Page files may be written in any format supported by
|
61
|
+
[GitHub-Markup](http://github.com/github/markup) (except roff). By default,
|
62
|
+
Gollum recognizes the following extensions:
|
63
|
+
|
64
|
+
* ASCIIDoc: .asciidoc
|
65
|
+
* Creole: .creole
|
66
|
+
* Markdown: .markdown, .mdown, .mkdn, .mkd, .md
|
67
|
+
* Org Mode: .org
|
68
|
+
* Pod: .pod
|
69
|
+
* RDoc: .rdoc
|
70
|
+
* ReStructuredText: .rest.txt, .rst.txt, .rest, .rst
|
71
|
+
* Textile: .textile
|
72
|
+
* MediaWiki: .mediawiki, .wiki
|
73
|
+
|
74
|
+
You may also register your own extensions and parsers:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
Gollum::Markup.register(:angry, "Angry") do |content|
|
78
|
+
content.upcase
|
79
|
+
end
|
80
|
+
```
|
81
|
+
|
82
|
+
Gollum detects the page file format via the extension, so files must have one
|
83
|
+
of the default or registered extensions in order to be converted.
|
84
|
+
|
85
|
+
Page file names may contain any printable UTF-8 character except space
|
86
|
+
(U+0020) and forward slash (U+002F). If you commit a page file with any of
|
87
|
+
these characters in the name it will not be accessible via the web interface.
|
88
|
+
|
89
|
+
Even though page files may be placed in any directory, there is still only a
|
90
|
+
single namespace for page names, so all page files should have globally unique
|
91
|
+
names regardless of where they are located in the repository.
|
92
|
+
|
93
|
+
The special page file `Home.ext` (where the extension is one of the supported
|
94
|
+
formats) will be used as the entrance page to your wiki. If it is missing, an
|
95
|
+
automatically generated table of contents will be shown instead.
|
96
|
+
|
97
|
+
## SIDEBAR FILES
|
98
|
+
|
99
|
+
Sidebar files allow you to add a simple sidebar to your wiki. Sidebar files
|
100
|
+
are named `_Sidebar.ext` where the extension is one of the supported formats.
|
101
|
+
Sidebars affect all pages in their directory and any subdirectories that do not
|
102
|
+
have a sidebar file of their own.
|
103
|
+
|
104
|
+
## HEADER FILES
|
105
|
+
|
106
|
+
Header files allow you to add a simple header to your wiki. Header files must
|
107
|
+
be named `_Header.ext` where the extension is one of the supported formats.
|
108
|
+
Like sidebars, headers affect all pages in their directory and any
|
109
|
+
subdirectories that do not have a header file of their own.
|
110
|
+
|
111
|
+
## FOOTER FILES
|
112
|
+
|
113
|
+
Footer files allow you to add a simple footer to your wiki. Footer files must
|
114
|
+
be named `_Footer.ext` where the extension is one of the supported formats.
|
115
|
+
Like sidebars, footers affect all pages in their directory and any
|
116
|
+
subdirectories that do not have a footer file of their own.
|
117
|
+
|
118
|
+
## HTML SANITIZATION
|
119
|
+
|
120
|
+
For security and compatibility reasons Gollum wikis may not contain custom CSS
|
121
|
+
or JavaScript. These tags will be stripped from the converted HTML. See
|
122
|
+
`docs/sanitization.md` for more details on what tags and attributes are
|
123
|
+
allowed.
|
124
|
+
|
125
|
+
## TITLES
|
126
|
+
|
127
|
+
The first defined `h1` will override the default header on a page. There are
|
128
|
+
two ways to set a page title. The metadata syntax:
|
129
|
+
|
130
|
+
<!-- --- title: New Title -->
|
131
|
+
|
132
|
+
The first `h1` tag can be set to always override the page title, without
|
133
|
+
needing to use the metadata syntax. Start gollum with the `--h1-title` flag.
|
134
|
+
|
135
|
+
## BRACKET TAGS
|
136
|
+
|
137
|
+
A variety of Gollum tags use a double bracket syntax. For example:
|
138
|
+
|
139
|
+
[[Link]]
|
140
|
+
|
141
|
+
Some tags will accept attributes which are separated by pipe symbols. For
|
142
|
+
example:
|
143
|
+
|
144
|
+
[[Link|Page Title]]
|
145
|
+
|
146
|
+
In all cases, the first thing in the link is what is displayed on the page.
|
147
|
+
So, if the tag is an internal wiki link, the first thing in the tag will be
|
148
|
+
the link text displayed on the page. If the tag is an embedded image, the
|
149
|
+
first thing in the tag will be a path to an image file. Use this trick to
|
150
|
+
easily remember which order things should appear in tags.
|
151
|
+
|
152
|
+
Some formats, such as MediaWiki, support the opposite syntax:
|
153
|
+
|
154
|
+
[[Page Title|Link]]
|
155
|
+
|
156
|
+
## PAGE LINKS
|
157
|
+
|
158
|
+
To link to another Gollum wiki page, use the Gollum Page Link Tag.
|
159
|
+
|
160
|
+
[[Frodo Baggins]]
|
161
|
+
|
162
|
+
The above tag will create a link to the corresponding page file named
|
163
|
+
`Frodo-Baggins.ext` where `ext` may be any of the allowed extension types. The
|
164
|
+
conversion is as follows:
|
165
|
+
|
166
|
+
1. Replace any spaces (U+0020) with dashes (U+002D)
|
167
|
+
2. Replace any slashes (U+002F) with dashes (U+002D)
|
168
|
+
|
169
|
+
If you'd like the link text to be something that doesn't map directly to the
|
170
|
+
page name, you can specify the actual page name after a pipe:
|
171
|
+
|
172
|
+
[[Frodo|Frodo Baggins]]
|
173
|
+
|
174
|
+
The above tag will link to `Frodo-Baggins.ext` using "Frodo" as the link text.
|
175
|
+
|
176
|
+
The page file may exist anywhere in the directory structure of the repository.
|
177
|
+
Gollum does a breadth first search and uses the first match that it finds.
|
178
|
+
|
179
|
+
Here are a few more examples:
|
180
|
+
|
181
|
+
[[J. R. R. Tolkien]] -> J.-R.-R.-Tolkien.ext
|
182
|
+
[[Movies / The Hobbit]] -> Movies---The-Hobbit.ext
|
183
|
+
[[モルドール]] -> モルドール.ext
|
184
|
+
|
185
|
+
|
186
|
+
## EXTERNAL LINKS
|
187
|
+
|
188
|
+
As a convenience, simple external links can be placed within brackets and they
|
189
|
+
will be linked to the given URL with the URL as the link text. For example:
|
190
|
+
|
191
|
+
[[http://example.com]]
|
192
|
+
|
193
|
+
External links must begin with either "http://" or "https://". If you need
|
194
|
+
something more flexible, you can resort to the link syntax in the page's
|
195
|
+
underlying markup format.
|
196
|
+
|
197
|
+
|
198
|
+
## ABSOLUTE VS. RELATIVE VS. EXTERNAL PATH
|
199
|
+
|
200
|
+
For Gollum tags that operate on static files (images, PDFs, etc), the paths
|
201
|
+
may be referenced as either relative, absolute, or external. Relative paths
|
202
|
+
point to a static file relative to the page file within the directory
|
203
|
+
structure of the Gollum repo (even though after conversion, all page files
|
204
|
+
appear to be top level). These paths are NOT prefixed with a slash. For
|
205
|
+
example:
|
206
|
+
|
207
|
+
gollum.pdf
|
208
|
+
docs/diagram.png
|
209
|
+
|
210
|
+
Absolute paths point to a static file relative to the Gollum repo's
|
211
|
+
root, regardless of where the page file is stored within the directory
|
212
|
+
structure. These paths ARE prefixed with a slash. For example:
|
213
|
+
|
214
|
+
/pdfs/gollum.pdf
|
215
|
+
/docs/diagram.png
|
216
|
+
|
217
|
+
External paths are full URLs. An external path must begin with either
|
218
|
+
"http://" or "https://". For example:
|
219
|
+
|
220
|
+
http://example.com/pdfs/gollum.pdf
|
221
|
+
http://example.com/images/diagram.png
|
222
|
+
|
223
|
+
All of the examples in this README use relative paths, but you may use
|
224
|
+
whatever works best in your situation.
|
225
|
+
|
226
|
+
|
227
|
+
## FILE LINKS
|
228
|
+
|
229
|
+
To link to static files that are contained in the Gollum repository you should
|
230
|
+
use the Gollum File Link Tag.
|
231
|
+
|
232
|
+
[[Gollum|gollum.pdf]]
|
233
|
+
|
234
|
+
The first part of the tag is the link text. The path to the file appears after
|
235
|
+
the pipe.
|
236
|
+
|
237
|
+
|
238
|
+
## IMAGES
|
239
|
+
|
240
|
+
To display images that are contained in the Gollum repository you should use
|
241
|
+
the Gollum Image Tag. This will display the actual image on the page.
|
242
|
+
|
243
|
+
[[gollum.png]]
|
244
|
+
|
245
|
+
In addition to the simple format, there are a variety of options that you
|
246
|
+
can specify between pipe delimiters.
|
247
|
+
|
248
|
+
To specify alt text, use the `alt=` option. Default is no alt text.
|
249
|
+
|
250
|
+
[[gollum.png|alt=Gollum and his precious wiki]]
|
251
|
+
|
252
|
+
To place the image in a frame, use the `frame` option. When combined with the
|
253
|
+
`alt=` option, the alt text will be used as a caption as well. Default is no
|
254
|
+
frame.
|
255
|
+
|
256
|
+
[[gollum.png|frame|alt=Gollum and his precious wiki]]
|
257
|
+
|
258
|
+
To specify the alignment of the image on the page, use the `align=` option.
|
259
|
+
Possible values are `left`, `center`, and `right`. Default is `left`.
|
260
|
+
|
261
|
+
[[gollum.png|align=center]]
|
262
|
+
|
263
|
+
To float an image so that text flows around it, use the `float` option. When
|
264
|
+
`float` is specified, only `left` and `right` are valid `align` options.
|
265
|
+
Default is not floating. When floating is activated but no alignment is
|
266
|
+
specified, default alignment is `left`.
|
267
|
+
|
268
|
+
[[gollum.png|float]]
|
269
|
+
|
270
|
+
By default text will fill up all the space around the image. To control how
|
271
|
+
much should show up use this tag to stop and start a new block so that
|
272
|
+
additional content doesn't fill in.
|
273
|
+
|
274
|
+
[[_]]
|
275
|
+
|
276
|
+
To specify a max-width, use the `width=` option. Units must be specified in
|
277
|
+
either `px` or `em`.
|
278
|
+
|
279
|
+
[[gollum.png|width=400px]]
|
280
|
+
|
281
|
+
To specify a max-height, use the `height=` option. Units must be specified in
|
282
|
+
either `px` or `em`.
|
283
|
+
|
284
|
+
[[gollum.png|height=300px]]
|
285
|
+
|
286
|
+
Any of these options may be composed together by simply separating them with
|
287
|
+
pipes.
|
288
|
+
|
289
|
+
|
290
|
+
## ESCAPING GOLLUM TAGS
|
291
|
+
|
292
|
+
If you need the literal text of a wiki or static link to show up in your final
|
293
|
+
wiki page, simply preface the link with a single quote (like in LISP):
|
294
|
+
|
295
|
+
'[[Page Link]]
|
296
|
+
'[[File Link|file.pdf]]
|
297
|
+
'[[image.jpg]]
|
298
|
+
|
299
|
+
This is useful for writing about the link syntax in your wiki pages.
|
300
|
+
|
301
|
+
## TABLE OF CONTENTS
|
302
|
+
|
303
|
+
Gollum has a special tag to insert a table of contents:
|
304
|
+
|
305
|
+
[[_TOC_]]
|
306
|
+
|
307
|
+
This tag is case sensitive, use all upper case. The TOC tag can be inserted
|
308
|
+
into the `_Header`, `_Footer` or `_Sidebar` files too.
|
309
|
+
|
310
|
+
There is also a wiki option `:universal_toc` which will display a
|
311
|
+
table of contents at the top of all your wiki pages if it is enabled:
|
312
|
+
|
313
|
+
```ruby
|
314
|
+
Gollum::Wiki.new("my-gollum-repo.git", {:universal_toc => true})
|
315
|
+
```
|
316
|
+
|
317
|
+
## SYNTAX HIGHLIGHTING
|
318
|
+
|
319
|
+
In page files you can get automatic syntax highlighting for a wide range of
|
320
|
+
languages (courtesy of [Pygments](http://pygments.org/) - must install
|
321
|
+
separately) by using the following syntax:
|
322
|
+
|
323
|
+
```ruby
|
324
|
+
def foo
|
325
|
+
puts 'bar'
|
326
|
+
end
|
327
|
+
```
|
328
|
+
|
329
|
+
The block must start with three backticks, at the beginning of a line or
|
330
|
+
indented with any number of spaces or tabs.
|
331
|
+
After that comes the name of the language that is contained by the
|
332
|
+
block. The language must be one of the `short name` lexer strings supported by
|
333
|
+
Pygments. See the [list of lexers](http://pygments.org/docs/lexers/) for valid
|
334
|
+
options.
|
335
|
+
|
336
|
+
The block contents should be indented at the same level than the opening backticks.
|
337
|
+
If the block contents are indented with an additional two spaces or one tab,
|
338
|
+
then that whitespace will be ignored (this makes the blocks easier to read in plaintext).
|
339
|
+
|
340
|
+
The block must end with three backticks indented at the same level than the opening
|
341
|
+
backticks.
|
342
|
+
|
343
|
+
### GITHUB SYNTAX HIGHLIGHTING
|
344
|
+
|
345
|
+
As an extra feature, you can syntax highlight a file from your repository, allowing
|
346
|
+
you keep some of your sample code in the main repository. The code-snippet is
|
347
|
+
updated when the wiki is rebuilt. You include github code like this:
|
348
|
+
|
349
|
+
```html:github:gollum/gollum-lib/master/test/file_view/1_file.txt```
|
350
|
+
|
351
|
+
This will make the builder look at the **gollum user**, in the **gollum-lib project**,
|
352
|
+
in the **master branch**, at path **test/file_view/1_file.txt**. It will be
|
353
|
+
rewritten to:
|
354
|
+
|
355
|
+
```html
|
356
|
+
<ol class="tree">
|
357
|
+
<li class="file"><a href="0">0</a></li>
|
358
|
+
</ol>
|
359
|
+
```
|
360
|
+
|
361
|
+
Which will be parsed as HTML code during the Pygments run, and thereby coloured
|
362
|
+
appropriately.
|
363
|
+
|
364
|
+
## MATHEMATICAL EQUATIONS
|
365
|
+
|
366
|
+
Start gollum with the `--mathjax` flag. Read more about [MathJax](http://docs.mathjax.org/en/latest/index.html) on the web. Gollum uses the `TeX-AMS-MML_HTMLorMML` config with the `autoload-all` extension.
|
367
|
+
|
368
|
+
Inline math:
|
369
|
+
|
370
|
+
- $2^2$
|
371
|
+
- `\\(2^2\\)`
|
372
|
+
|
373
|
+
Display math:
|
374
|
+
|
375
|
+
- $$2^2$$
|
376
|
+
- [2^2]
|
377
|
+
|
378
|
+
## SEQUENCE DIAGRAMS
|
379
|
+
|
380
|
+
You may imbed sequence diagrams into your wiki page (rendered by
|
381
|
+
[WebSequenceDiagrams](http://www.websequencediagrams.com) by using the
|
382
|
+
following syntax:
|
383
|
+
|
384
|
+
{{{{{{ blue-modern
|
385
|
+
alice->bob: Test
|
386
|
+
bob->alice: Test response
|
387
|
+
}}}}}}
|
388
|
+
|
389
|
+
You can replace the string "blue-modern" with any supported style.
|
390
|
+
|
391
|
+
## API DOCUMENTATION
|
392
|
+
|
393
|
+
Initialize the `Gollum::Repo` object:
|
394
|
+
|
395
|
+
```ruby
|
396
|
+
# Require rubygems if necessary
|
397
|
+
require 'rubygems'
|
398
|
+
|
399
|
+
# Require the Gollum library
|
400
|
+
require 'gollum-lib'
|
401
|
+
|
402
|
+
# Create a new Gollum::Wiki object by initializing it with the path to the
|
403
|
+
# Git repository.
|
404
|
+
wiki = Gollum::Wiki.new("my-gollum-repo.git")
|
405
|
+
# => <Gollum::Wiki>
|
406
|
+
```
|
407
|
+
|
408
|
+
By default, internal wiki links are all absolute from the root. To specify a different
|
409
|
+
base path, you can specify the `:base_path` option:
|
410
|
+
|
411
|
+
```ruby
|
412
|
+
wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki")
|
413
|
+
```
|
414
|
+
|
415
|
+
Note that `base_path` just modifies the links.
|
416
|
+
|
417
|
+
Get the latest version of the given human or canonical page name:
|
418
|
+
|
419
|
+
```ruby
|
420
|
+
page = wiki.page('page-name')
|
421
|
+
# => <Gollum::Page>
|
422
|
+
|
423
|
+
page.raw_data
|
424
|
+
# => "# My wiki page"
|
425
|
+
|
426
|
+
page.formatted_data
|
427
|
+
# => "<h1>My wiki page</h1>"
|
428
|
+
|
429
|
+
page.format
|
430
|
+
# => :markdown
|
431
|
+
|
432
|
+
vsn = page.version
|
433
|
+
# => <Grit::Commit>
|
434
|
+
|
435
|
+
vsn.id
|
436
|
+
# => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
|
437
|
+
```
|
438
|
+
|
439
|
+
Get the footer (if any) for a given page:
|
440
|
+
|
441
|
+
```ruby
|
442
|
+
page.footer
|
443
|
+
# => <Gollum::Page>
|
444
|
+
```
|
445
|
+
|
446
|
+
Get the header (if any) for a given page:
|
447
|
+
|
448
|
+
```ruby
|
449
|
+
page.header
|
450
|
+
# => <Gollum::Page>
|
451
|
+
```
|
452
|
+
|
453
|
+
Get a list of versions for a given page:
|
454
|
+
|
455
|
+
```ruby
|
456
|
+
vsns = wiki.page('page-name').versions
|
457
|
+
# => [<Grit::Commit, <Grit::Commit, <Grit::Commit>]
|
458
|
+
|
459
|
+
vsns.first.id
|
460
|
+
# => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
|
461
|
+
|
462
|
+
vsns.first.authored_date
|
463
|
+
# => Sun Mar 28 19:11:21 -0700 2010
|
464
|
+
```
|
465
|
+
|
466
|
+
Get a specific version of a given canonical page file:
|
467
|
+
|
468
|
+
```ruby
|
469
|
+
wiki.page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
|
470
|
+
```
|
471
|
+
|
472
|
+
Get the latest version of a given static file:
|
473
|
+
|
474
|
+
```ruby
|
475
|
+
file = wiki.file('asset.js')
|
476
|
+
# => <Gollum::File>
|
477
|
+
|
478
|
+
file.raw_data
|
479
|
+
# => "alert('hello');"
|
480
|
+
|
481
|
+
file.version
|
482
|
+
# => <Grit::Commit>
|
483
|
+
```
|
484
|
+
|
485
|
+
Get a specific version of a given static file:
|
486
|
+
|
487
|
+
```ruby
|
488
|
+
wiki.file('asset.js', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
|
489
|
+
```
|
490
|
+
|
491
|
+
Get an in-memory Page preview (useful for generating previews for web
|
492
|
+
interfaces):
|
493
|
+
|
494
|
+
```ruby
|
495
|
+
preview = wiki.preview_page("My Page", "# Contents", :markdown)
|
496
|
+
preview.formatted_data
|
497
|
+
# => "<h1>Contents</h1>"
|
498
|
+
```
|
499
|
+
|
500
|
+
Methods that write to the repository require a Hash of commit data that takes
|
501
|
+
the following form:
|
502
|
+
|
503
|
+
```ruby
|
504
|
+
commit = { :message => 'commit message',
|
505
|
+
:name => 'Tom Preston-Werner',
|
506
|
+
:email => 'tom@github.com' }
|
507
|
+
```
|
508
|
+
|
509
|
+
Write a new version of a page (the file will be created if it does not already
|
510
|
+
exist) and commit the change. The file will be written at the repo root.
|
511
|
+
|
512
|
+
```ruby
|
513
|
+
wiki.write_page('Page Name', :markdown, 'Page contents', commit)
|
514
|
+
```
|
515
|
+
|
516
|
+
Update an existing page. If the format is different than the page's current
|
517
|
+
format, the file name will be changed to reflect the new format.
|
518
|
+
|
519
|
+
```ruby
|
520
|
+
page = wiki.page('Page Name')
|
521
|
+
wiki.update_page(page, page.name, page.format, 'Page contents', commit)
|
522
|
+
```
|
523
|
+
|
524
|
+
To delete a page and commit the change:
|
525
|
+
|
526
|
+
```ruby
|
527
|
+
wiki.delete_page(page, commit)
|
528
|
+
```
|
529
|
+
|
530
|
+
## WINDOWS FILENAME VALIDATION
|
531
|
+
|
532
|
+
Note that filenames on windows must not contain any of the following characters `\ / : * ? " < > |`. See [this support article](http://support.microsoft.com/kb/177506) for details.
|
533
|
+
|
534
|
+
## CONTRIBUTE
|
535
|
+
|
536
|
+
If you'd like to hack on Gollum-lib, start by forking the repo on GitHub:
|
537
|
+
|
538
|
+
http://github.com/gollum/gollum-lib
|
539
|
+
|
540
|
+
To get all of the dependencies, install the gem first. The best way to get
|
541
|
+
your changes merged back into core is as follows:
|
542
|
+
|
543
|
+
1. Clone down your fork
|
544
|
+
1. Create a thoughtfully named topic branch to contain your change
|
545
|
+
1. Hack away
|
546
|
+
1. Add tests and make sure everything still passes by running `rake`
|
547
|
+
1. If you are adding new functionality, document it in the README
|
548
|
+
1. Do not change the version number, I will do that on my end
|
549
|
+
1. If necessary, rebase your commits into logical chunks, without errors
|
550
|
+
1. Push the branch up to GitHub
|
551
|
+
1. Send a pull request to the gollum/gollum-lib project.
|
552
|
+
|
553
|
+
## RELEASING
|
554
|
+
|
555
|
+
Gollum-lib uses [Semantic Versioning](http://semver.org/). Having `x.y.z` :
|
556
|
+
|
557
|
+
For z releases:
|
558
|
+
|
559
|
+
```bash
|
560
|
+
$ rake bump
|
561
|
+
$ rake release
|
562
|
+
```
|
563
|
+
|
564
|
+
For x.y releases:
|
565
|
+
|
566
|
+
```bash
|
567
|
+
$ rake gemspec
|
568
|
+
$ rake release
|
569
|
+
```
|
570
|
+
|
571
|
+
## BUILDING THE GEM FROM MASTER
|
572
|
+
|
573
|
+
```bash
|
574
|
+
$ gem uninstall -aIx gollum-lib
|
575
|
+
$ git clone https://github.com/gollum/gollum-lib.git
|
576
|
+
$ cd gollum-lib
|
577
|
+
gollum-lib$ rake build
|
578
|
+
gollum-lib$ gem install --no-ri --no-rdoc pkg/gollum-lib*.gem
|
579
|
+
```
|
580
|
+
|
581
|
+
## RUN THE TESTS
|
582
|
+
|
583
|
+
```bash
|
584
|
+
$ bundle install
|
585
|
+
$ bundle exec rake test
|
586
|
+
```
|
587
|
+
|
588
|
+
## WORK WITH TEST REPOS
|
589
|
+
|
590
|
+
An example of how to add a test file to the bare repository `lotr.git`.
|
591
|
+
|
592
|
+
```bash
|
593
|
+
$ mkdir tmp; cd tmp
|
594
|
+
$ git clone ../lotr.git/ .
|
595
|
+
Cloning into '.'...
|
596
|
+
done.
|
597
|
+
$ git log
|
598
|
+
$ echo "test" > test.md
|
599
|
+
$ git add . ; git commit -am "Add test"
|
600
|
+
$ git push ../lotr.git/ master
|
601
|
+
```
|