rtfmd 0.10301.17

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