RTFMd 0.10301.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +93 -0
- data/LICENSE +21 -0
- data/README.md +387 -0
- data/RTFMd.gemspec +78 -0
- data/Rakefile +138 -0
- data/bin/rtfm +12 -0
- data/docs/sanitization.md +32 -0
- data/lib/gollum.rb +40 -0
- data/lib/gollum/blob_entry.rb +78 -0
- data/lib/gollum/committer.rb +217 -0
- data/lib/gollum/file.rb +64 -0
- data/lib/gollum/frontend/app.rb +94 -0
- data/lib/gollum/frontend/public/css/gollum.css +660 -0
- data/lib/gollum/frontend/public/css/ie7.css +69 -0
- data/lib/gollum/frontend/public/css/template.css +381 -0
- data/lib/gollum/frontend/public/images/icon-sprite.png +0 -0
- data/lib/gollum/frontend/public/javascript/gollum.js +137 -0
- data/lib/gollum/frontend/public/javascript/gollum.placeholder.js +54 -0
- data/lib/gollum/frontend/public/javascript/jquery.color.js +123 -0
- data/lib/gollum/frontend/public/javascript/jquery.js +7179 -0
- data/lib/gollum/frontend/templates/error.mustache +8 -0
- data/lib/gollum/frontend/templates/layout.mustache +28 -0
- data/lib/gollum/frontend/templates/page.mustache +32 -0
- data/lib/gollum/frontend/templates/pages.mustache +34 -0
- data/lib/gollum/frontend/views/error.rb +7 -0
- data/lib/gollum/frontend/views/layout.rb +24 -0
- data/lib/gollum/frontend/views/page.rb +53 -0
- data/lib/gollum/frontend/views/pages.rb +19 -0
- data/lib/gollum/git_access.rb +248 -0
- data/lib/gollum/markup.rb +389 -0
- data/lib/gollum/page.rb +374 -0
- data/lib/gollum/pagination.rb +61 -0
- data/lib/gollum/sanitization.rb +161 -0
- data/lib/gollum/wiki.rb +378 -0
- metadata +358 -0
data/HISTORY.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# git
|
2
|
+
|
3
|
+
* Minor
|
4
|
+
* Add a way to configure the `#id_prefix` property of Sanitization
|
5
|
+
objects.
|
6
|
+
* Bug Fixes
|
7
|
+
* Include the language of the code snippet when making a uniquely
|
8
|
+
identifiable sha of a code snippet while rendering a page.
|
9
|
+
|
10
|
+
# 1.3.1 / 2011-07-21
|
11
|
+
|
12
|
+
* Major Enhancements
|
13
|
+
* Allow prefixed ID attributes in headers to support internal linking
|
14
|
+
(#146).
|
15
|
+
* Markdown pages are rendered through Redcarpet by default (#176).
|
16
|
+
* Minor Enhancements
|
17
|
+
* Remove Edit button on Preview pages (#164).
|
18
|
+
* Simplify Wiki#inspect and Page#inspect.
|
19
|
+
* Bug Fixes
|
20
|
+
* Fixed broken preview functionality (#157).
|
21
|
+
* Fixed sidebar/footer rendering problems related to whitespace (#145).
|
22
|
+
|
23
|
+
# 1.3.0 / 2011-04-25
|
24
|
+
|
25
|
+
* Major Enhancements
|
26
|
+
* Listing of all Pages
|
27
|
+
* Support for running Gollum under a separate branch.
|
28
|
+
* Minor Enhancements
|
29
|
+
* Fix a security issue with rendering Mathjax.
|
30
|
+
|
31
|
+
# 1.2.0 / 2011-03-11
|
32
|
+
|
33
|
+
* Major Enhancements
|
34
|
+
* Major HTML/CSS/JS overhaul.
|
35
|
+
* Add Sidebars (similar to Footers).
|
36
|
+
* Add commit reverts.
|
37
|
+
* Minor Enhancements
|
38
|
+
* Optimization in source code highlighting, resulting in a huge
|
39
|
+
decrease in rendering time.
|
40
|
+
* Security fixes related to source code highlighting.
|
41
|
+
|
42
|
+
* Major Enhancements
|
43
|
+
* Add Page sidebars, similar to Page footers.
|
44
|
+
* Add the ability to revert commits to the wiki.
|
45
|
+
* Add MediaWiki support.
|
46
|
+
* Minor Enhancements
|
47
|
+
* Add `:sanitization` and `:history_sanitization` options for customizing
|
48
|
+
how `Sanitize.clean` modifies formatted wiki content.
|
49
|
+
* Add `--config` option for the command line, to specify a ruby file that is
|
50
|
+
run during startup.
|
51
|
+
* Provide access to a parsed Nokogiri::DocumentFragment during markup
|
52
|
+
rendering for added customization.
|
53
|
+
* Bug Fixes
|
54
|
+
* Use `@wiki.page_class` in Gollum::Markup where appropriate (#63).
|
55
|
+
* Fix parsing of Org mode file links (#87).
|
56
|
+
|
57
|
+
# 1.1.0 / 2010-10-28
|
58
|
+
|
59
|
+
* Major Enhancements
|
60
|
+
* Optimize page write/update/delete to use Grit::Index::read_tree instead
|
61
|
+
of manually recreating entire index contents.
|
62
|
+
* Added --irb option for the gollum command.
|
63
|
+
* Update working dir (if present) when edited via the API (#6)
|
64
|
+
* Add basic `git grep` based search for repos.
|
65
|
+
* Minor Enhancements
|
66
|
+
* Support a `:gollum_path` Sinatra setting for `Precious::App`
|
67
|
+
* Add Wiki#size to efficiently count pages without loading them.
|
68
|
+
* Add the correct content type when serving files from the frontend.
|
69
|
+
* Add --host option and default it to 127.0.0.1.
|
70
|
+
* Allow anchors in page links, such as `[[Abc#header]]`.
|
71
|
+
* All pages retrieved with a SHA add `rel="nofollow"` to all
|
72
|
+
page links.
|
73
|
+
* Bug Fixes
|
74
|
+
* Increase minimum Sanitize version requirement to 1.1.0.
|
75
|
+
1.0.x versions of Sanitize require Hpricot instead of Nokogiri
|
76
|
+
and have bugs that may allow non-whitelisted HTML to sneak
|
77
|
+
through.
|
78
|
+
* Introduce Ruby 1.9 compatibility fixes.
|
79
|
+
* Commit hashes are normalized so that missing author data is replaced with
|
80
|
+
anonymous info.
|
81
|
+
* Prevent `Gollum::Wiki#write_page` from clobbering existing pages.
|
82
|
+
* Handle duplicate page errors in frontend.
|
83
|
+
* Fix bugs trying to retrieve pages with invalid names.
|
84
|
+
* CGI escape page names in links and redirects.
|
85
|
+
|
86
|
+
# 1.0.1 / 2010-08-12
|
87
|
+
|
88
|
+
* Bug Fixes
|
89
|
+
* Force Grit dep to 2.1 or higher.
|
90
|
+
|
91
|
+
# 1.0.0 / 2010-08-12
|
92
|
+
|
93
|
+
* Open Source Birthday!
|
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,387 @@
|
|
1
|
+
RTFMd -- fork of gollum
|
2
|
+
========================
|
3
|
+
|
4
|
+
## FORK
|
5
|
+
|
6
|
+
Forked from `defunkt/gollum`:
|
7
|
+
|
8
|
+
* Sinatra mountable app
|
9
|
+
* Stylized to look like ronn HTML man pages
|
10
|
+
* Read-only
|
11
|
+
* Multiple wiki repositories
|
12
|
+
* Support Markdown (and ronn)
|
13
|
+
|
14
|
+
## DESCRIPTION
|
15
|
+
|
16
|
+
Gollum is a simple wiki system built on top of Git that powers GitHub Wikis.
|
17
|
+
|
18
|
+
Gollum wikis are simply Git repositories that adhere to a specific format.
|
19
|
+
Gollum pages may be written in a variety of formats and can be edited in a
|
20
|
+
number of ways depending on your needs. You can edit your wiki locally:
|
21
|
+
|
22
|
+
* With your favorite text editor or IDE (changes will be visible after committing).
|
23
|
+
* With the Gollum Ruby API.
|
24
|
+
|
25
|
+
Gollum follows the rules of [Semantic Versioning](http://semver.org/) and uses
|
26
|
+
[TomDoc](http://tomdoc.org/) for inline documentation.
|
27
|
+
|
28
|
+
|
29
|
+
## RUNNING
|
30
|
+
|
31
|
+
To view your Gollum repository locally via the built in web
|
32
|
+
interface, simply install the Gollum gem, navigate to your repository via the
|
33
|
+
command line, and run the executable:
|
34
|
+
|
35
|
+
bin/golem
|
36
|
+
|
37
|
+
This will start up a web server running the Gollum frontend and you can view
|
38
|
+
your wiki at http://localhost:3000
|
39
|
+
|
40
|
+
## REPO STRUCTURE
|
41
|
+
|
42
|
+
A Gollum repository's contents are designed to be human editable. Page content
|
43
|
+
is written in `page files` and may be organized into directories any way you
|
44
|
+
choose. Special footers can be created in `footer files`. Other content
|
45
|
+
(images, PDFs, etc) may also be present and organized in the same way.
|
46
|
+
|
47
|
+
|
48
|
+
## PAGE FILES
|
49
|
+
|
50
|
+
Page files may be written in Markdown with extensions:
|
51
|
+
|
52
|
+
* Markdown: .mkd, .markdown, .mdown, .mkdn, .md
|
53
|
+
* ronn: .ronn
|
54
|
+
|
55
|
+
Gollum detects the page file format via the extension, so files must have one
|
56
|
+
of the supported extensions in order to be converted.
|
57
|
+
|
58
|
+
Page file names may contain any printable UTF-8 character except space
|
59
|
+
(U+0020) and forward slash (U+002F). If you commit a page file with any of
|
60
|
+
these characters in the name it will not be accessible via the web interface.
|
61
|
+
|
62
|
+
Even though page files may be placed in any directory, there is still only a
|
63
|
+
single namespace for page names, so all page files should have globally unique
|
64
|
+
names regardless of where they are located in the repository.
|
65
|
+
|
66
|
+
The special page file `README.mkd` or `Home.mkd` (where the extension is
|
67
|
+
one of the supported formats) will be used as the entrance page to your
|
68
|
+
wiki. If it is missing, an automatically generated table of contents
|
69
|
+
will be shown instead.
|
70
|
+
|
71
|
+
## SIDEBAR FILES
|
72
|
+
|
73
|
+
Sidebar files allow you to add a simple sidebar to your wiki. Sidebar files
|
74
|
+
are named `_Sidebar.mkd` where the extension is one of the supported formats.
|
75
|
+
Sidebars affect all pages in their directory and any subdirectories that do not
|
76
|
+
have a sidebar file of their own.
|
77
|
+
|
78
|
+
## FOOTER FILES
|
79
|
+
|
80
|
+
Footer files allow you to add a simple footer to your wiki. Footer files must
|
81
|
+
be named `_Footer.mkd` where the extension is one of the supported formats.
|
82
|
+
Like sidebars, footers affect all pages in their directory and any
|
83
|
+
subdirectories that do not have a footer file of their own.
|
84
|
+
|
85
|
+
|
86
|
+
## HTML SANITIZATION
|
87
|
+
|
88
|
+
For security and compatibility reasons Gollum wikis may not contain custom CSS
|
89
|
+
or JavaScript. These tags will be stripped from the converted HTML. See
|
90
|
+
`docs/sanitization.mkd` for more details on what tags and attributes are
|
91
|
+
allowed.
|
92
|
+
|
93
|
+
|
94
|
+
## BRACKET TAGS
|
95
|
+
|
96
|
+
A variety of Gollum tags use a double bracket syntax. For example:
|
97
|
+
|
98
|
+
[[Link]]
|
99
|
+
|
100
|
+
Some tags will accept attributes which are separated by pipe symbols. For
|
101
|
+
example:
|
102
|
+
|
103
|
+
[[Link|Page Title]]
|
104
|
+
|
105
|
+
In all cases, the first thing in the link is what is displayed on the page.
|
106
|
+
So, if the tag is an internal wiki link, the first thing in the tag will be
|
107
|
+
the link text displayed on the page. If the tag is an embedded image, the
|
108
|
+
first thing in the tag will be a path to an image file. Use this trick to
|
109
|
+
easily remember which order things should appear in tags.
|
110
|
+
|
111
|
+
Some formats, such as MediaWiki, support the opposite syntax:
|
112
|
+
|
113
|
+
[[Page Title|Link]]
|
114
|
+
|
115
|
+
## PAGE LINKS
|
116
|
+
|
117
|
+
To link to another Gollum wiki page, use the Gollum Page Link Tag.
|
118
|
+
|
119
|
+
[[Frodo Baggins]]
|
120
|
+
|
121
|
+
The above tag will create a link to the corresponding page file named
|
122
|
+
`Frodo-Baggins.mkd` where `ext` may be any of the allowed extension types. The
|
123
|
+
conversion is as follows:
|
124
|
+
|
125
|
+
1. Replace any spaces (U+0020) with dashes (U+002D)
|
126
|
+
2. Replace any slashes (U+002F) with dashes (U+002D)
|
127
|
+
|
128
|
+
If you'd like the link text to be something that doesn't map directly to the
|
129
|
+
page name, you can specify the actual page name after a pipe:
|
130
|
+
|
131
|
+
[[Frodo|Frodo Baggins]]
|
132
|
+
|
133
|
+
The above tag will link to `Frodo-Baggins.mkd` using "Frodo" as the link text.
|
134
|
+
|
135
|
+
The page file may exist anywhere in the directory structure of the repository.
|
136
|
+
Gollum does a breadth first search and uses the first match that it finds.
|
137
|
+
|
138
|
+
Here are a few more examples:
|
139
|
+
|
140
|
+
[[J. R. R. Tolkien]] -> J.-R.-R.-Tolkien.mkd
|
141
|
+
[[Movies / The Hobbit]] -> Movies---The-Hobbit.mkd
|
142
|
+
[[モルドール]] -> モルドール.mkd
|
143
|
+
|
144
|
+
|
145
|
+
## EXTERNAL LINKS
|
146
|
+
|
147
|
+
As a convenience, simple external links can be placed within brackets and they
|
148
|
+
will be linked to the given URL with the URL as the link text. For example:
|
149
|
+
|
150
|
+
[[http://example.com]]
|
151
|
+
|
152
|
+
External links must begin with either "http://" or "https://". If you need
|
153
|
+
something more flexible, you can resort to the link syntax in the page's
|
154
|
+
underlying markup format.
|
155
|
+
|
156
|
+
|
157
|
+
## ABSOLUTE VS. RELATIVE VS. EXTERNAL PATH
|
158
|
+
|
159
|
+
For Gollum tags that operate on static files (images, PDFs, etc), the paths
|
160
|
+
may be referenced as either relative, absolute, or external. Relative paths
|
161
|
+
point to a static file relative to the page file within the directory
|
162
|
+
structure of the Gollum repo (even though after conversion, all page files
|
163
|
+
appear to be top level). These paths are NOT prefixed with a slash. For
|
164
|
+
example:
|
165
|
+
|
166
|
+
gollum.pdf
|
167
|
+
docs/diagram.png
|
168
|
+
|
169
|
+
Absolute paths point to a static file relative to the Gollum repo's
|
170
|
+
root, regardless of where the page file is stored within the directory
|
171
|
+
structure. These paths ARE prefixed with a slash. For example:
|
172
|
+
|
173
|
+
/pdfs/gollum.pdf
|
174
|
+
/docs/diagram.png
|
175
|
+
|
176
|
+
External paths are full URLs. An external path must begin with either
|
177
|
+
"http://" or "https://". For example:
|
178
|
+
|
179
|
+
http://example.com/pdfs/gollum.pdf
|
180
|
+
http://example.com/images/diagram.png
|
181
|
+
|
182
|
+
All of the examples in this README use relative paths, but you may use
|
183
|
+
whatever works best in your situation.
|
184
|
+
|
185
|
+
|
186
|
+
## FILE LINKS
|
187
|
+
|
188
|
+
To link to static files that are contained in the Gollum repository you should
|
189
|
+
use the Gollum File Link Tag.
|
190
|
+
|
191
|
+
[[Gollum|gollum.pdf]]
|
192
|
+
|
193
|
+
The first part of the tag is the link text. The path to the file appears after
|
194
|
+
the pipe.
|
195
|
+
|
196
|
+
|
197
|
+
## IMAGES
|
198
|
+
|
199
|
+
To display images that are contained in the Gollum repository you should use
|
200
|
+
the Gollum Image Tag. This will display the actual image on the page.
|
201
|
+
|
202
|
+
[[gollum.png]]
|
203
|
+
|
204
|
+
In addition to the simple format, there are a variety of options that you
|
205
|
+
can specify between pipe delimiters.
|
206
|
+
|
207
|
+
To specify alt text, use the `alt=` option. Default is no alt text.
|
208
|
+
|
209
|
+
[[gollum.png|alt=Gollum and his precious wiki]]
|
210
|
+
|
211
|
+
To place the image in a frame, use the `frame` option. When combined with the
|
212
|
+
`alt=` option, the alt text will be used as a caption as well. Default is no
|
213
|
+
frame.
|
214
|
+
|
215
|
+
[[gollum.png|frame|alt=Gollum and his precious wiki]]
|
216
|
+
|
217
|
+
To specify the alignment of the image on the page, use the `align=` option.
|
218
|
+
Possible values are `left`, `center`, and `right`. Default is `left`.
|
219
|
+
|
220
|
+
[[gollum.png|align=center]]
|
221
|
+
|
222
|
+
To float an image so that text flows around it, use the `float` option. When
|
223
|
+
`float` is specified, only `left` and `right` are valid `align` options.
|
224
|
+
Default is not floating. When floating is activated but no alignment is
|
225
|
+
specified, default alignment is `left`.
|
226
|
+
|
227
|
+
[[gollum.png|float]]
|
228
|
+
|
229
|
+
To specify a max-width, use the `width=` option. Units must be specified in
|
230
|
+
either `px` or `em`.
|
231
|
+
|
232
|
+
[[gollum.png|width=400px]]
|
233
|
+
|
234
|
+
To specify a max-height, use the `height=` option. Units must be specified in
|
235
|
+
either `px` or `em`.
|
236
|
+
|
237
|
+
[[gollum.png|height=300px]]
|
238
|
+
|
239
|
+
Any of these options may be composed together by simply separating them with
|
240
|
+
pipes.
|
241
|
+
|
242
|
+
|
243
|
+
## ESCAPING GOLLUM TAGS
|
244
|
+
|
245
|
+
If you need the literal text of a wiki or static link to show up in your final
|
246
|
+
wiki page, simply preface the link with a single quote (like in LISP):
|
247
|
+
|
248
|
+
'[[Page Link]]
|
249
|
+
'[[File Link|file.pdf]]
|
250
|
+
'[[image.jpg]]
|
251
|
+
|
252
|
+
This is useful for writing about the link syntax in your wiki pages.
|
253
|
+
|
254
|
+
|
255
|
+
## SYNTAX HIGHLIGHTING
|
256
|
+
|
257
|
+
In page files you can get automatic syntax highlighting for a wide range of
|
258
|
+
languages (courtesy of [Pygments](http://pygments.org/) - must install
|
259
|
+
separately) by using the following syntax:
|
260
|
+
|
261
|
+
```ruby
|
262
|
+
def foo
|
263
|
+
puts 'bar'
|
264
|
+
end
|
265
|
+
```
|
266
|
+
|
267
|
+
The block must start with three backticks (as the first characters on the
|
268
|
+
line). After that comes the name of the language that is contained by the
|
269
|
+
block. The language must be one of the `short name` lexer strings supported by
|
270
|
+
Pygments. See the [list of lexers](http://pygments.org/docs/lexers/) for valid
|
271
|
+
options.
|
272
|
+
|
273
|
+
If the block contents are indented two spaces or one tab, then that whitespace
|
274
|
+
will be ignored (this makes the blocks easier to read in plaintext).
|
275
|
+
|
276
|
+
The block must end with three backticks as the first characters on a
|
277
|
+
line.
|
278
|
+
|
279
|
+
|
280
|
+
## API DOCUMENTATION
|
281
|
+
|
282
|
+
The Gollum API allows you to retrieve raw or formatted wiki content from a Git
|
283
|
+
repository, write new content to the repository, and collect various meta data
|
284
|
+
about the wiki as a whole.
|
285
|
+
|
286
|
+
Initialize the Gollum::Repo object:
|
287
|
+
|
288
|
+
# Require rubygems if necessary
|
289
|
+
require 'rubygems'
|
290
|
+
|
291
|
+
# Require the Gollum library
|
292
|
+
require 'gollum'
|
293
|
+
|
294
|
+
# Create a new Gollum::Wiki object by initializing it with the path to the
|
295
|
+
# Git repository.
|
296
|
+
wiki = Gollum::Wiki.new("my-gollum-repo.git")
|
297
|
+
# => <Gollum::Wiki>
|
298
|
+
|
299
|
+
By default, internal wiki links are all absolute from the root. To specify a different base path, you can specify the `:base_path` option:
|
300
|
+
|
301
|
+
wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki")
|
302
|
+
|
303
|
+
Get the latest version of the given human or canonical page name:
|
304
|
+
|
305
|
+
page = wiki.page('page-name')
|
306
|
+
# => <Gollum::Page>
|
307
|
+
|
308
|
+
page.raw_data
|
309
|
+
# => "# My wiki page"
|
310
|
+
|
311
|
+
page.formatted_data
|
312
|
+
# => "<h1>My wiki page</h1>"
|
313
|
+
|
314
|
+
page.format
|
315
|
+
# => :markdown
|
316
|
+
|
317
|
+
vsn = page.version
|
318
|
+
# => <Grit::Commit>
|
319
|
+
|
320
|
+
vsn.id
|
321
|
+
# => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
|
322
|
+
|
323
|
+
Get the footer (if any) for a given page:
|
324
|
+
|
325
|
+
page.footer
|
326
|
+
# => <Gollum::Page>
|
327
|
+
|
328
|
+
Get a list of versions for a given page:
|
329
|
+
|
330
|
+
vsns = wiki.page('page-name').versions
|
331
|
+
# => [<Grit::Commit, <Grit::Commit, <Grit::Commit>]
|
332
|
+
|
333
|
+
vsns.first.id
|
334
|
+
# => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
|
335
|
+
|
336
|
+
vsns.first.authored_date
|
337
|
+
# => Sun Mar 28 19:11:21 -0700 2010
|
338
|
+
|
339
|
+
Get a specific version of a given canonical page file:
|
340
|
+
|
341
|
+
wiki.page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
|
342
|
+
|
343
|
+
Get the latest version of a given static file:
|
344
|
+
|
345
|
+
file = wiki.file('asset.js')
|
346
|
+
# => <Gollum::File>
|
347
|
+
|
348
|
+
file.raw_data
|
349
|
+
# => "alert('hello');"
|
350
|
+
|
351
|
+
file.version
|
352
|
+
# => <Grit::Commit>
|
353
|
+
|
354
|
+
Get a specific version of a given static file:
|
355
|
+
|
356
|
+
wiki.file('asset.js', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
|
357
|
+
|
358
|
+
Get an in-memory Page preview (useful for generating previews for web
|
359
|
+
interfaces):
|
360
|
+
|
361
|
+
preview = wiki.preview_page("My Page", "# Contents", :markdown)
|
362
|
+
preview.formatted_data
|
363
|
+
# => "<h1>Contents</h1>"
|
364
|
+
|
365
|
+
Methods that write to the repository require a Hash of commit data that takes
|
366
|
+
the following form:
|
367
|
+
|
368
|
+
commit = { :message => 'commit message',
|
369
|
+
:name => 'Tom Preston-Werner',
|
370
|
+
:email => 'tom@github.com' }
|
371
|
+
|
372
|
+
Write a new version of a page (the file will be created if it does not already
|
373
|
+
exist) and commit the change. The file will be written at the repo root.
|
374
|
+
|
375
|
+
wiki.write_page('Page Name', :markdown, 'Page contents', commit)
|
376
|
+
|
377
|
+
Update an existing page. If the format is different than the page's current
|
378
|
+
format, the file name will be changed to reflect the new format.
|
379
|
+
|
380
|
+
page = wiki.page('Page Name')
|
381
|
+
wiki.update_page(page, page.name, page.format, 'Page contents', commit)
|
382
|
+
|
383
|
+
To delete a page and commit the change:
|
384
|
+
|
385
|
+
wiki.delete_page(page, commit)
|
386
|
+
|
387
|
+
|