gollum-lib 0.0.1 → 1.0.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-lib might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTAyOTk5OTcxZDkyNzQ2NmQzMDg4ZjBhMmQ1ZWE3NWJiYjcyNGFiMQ==
4
+ MGQxN2YxZWVjMDA0M2I0OTY5MzY4Y2JiZDg5NzkwMDA4OWZjYjg0NQ==
5
5
  data.tar.gz: !binary |-
6
- ZGU3YmFiYTRmZjIwMmEwMDcyMGRmODJmNjU3NDU2ZDQ2MGE3NGQzYg==
6
+ MGRkOTE4YjVhMWMxNzQ2MjI3NTYxNWMwZDRhNjAyYzA3NDQwMWFiYw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZDQ0OTg4MmMyZmZlM2ExZmVkMWRkZWJiNTZiNmMyMWQ5NDExNDY0NjcyZDY5
10
- ZDRiOTVhNjgwMmVjMzAyMmViNTM5NjZmMTc3Zjc3ZTcxOTY2Y2E2ODMyMmY0
11
- ZjE2NTQwMDNjZGZjOTU2OGY1Y2Y3OTZkNTM4NDZiMWM3YzMyYTc=
9
+ ZmJmNmQ3MmFhNDg5NTJmMzEzZmEyZDFkMGMyNzhlYjMxMzQ4MzUxYzllZGM0
10
+ ZGE5MjZmMDIyOWJkNzkyMzJhZTE0ODI0NGNkYjlhOTJjOTE4YTkxZDVhZTRk
11
+ ODk2YTMzMTc5MjFiMDIxZWNjYzg1Mjk4NjYzZDgyNzYwMDM3YzQ=
12
12
  data.tar.gz: !binary |-
13
- YTFlNjVmOTllYTk4ZjRiOTRhZDgxNGE5MDcyN2IzYzIyNTc5N2JmMmE1NjAw
14
- OGNhYjlhNzFkYWY2OGQ5ODIzNmE5ZTM1ODY0ZmZlNWQ1NzgzOTY2MjAzZjJk
15
- OTI4ZDdiMGIyNzBiYmExZmE3MjdjMTM0ZGQ3YTJkNjg0ODVmNTQ=
13
+ ZTdiYzA3MTI3MmU2MWQwNzM1ZDIwYzY0Y2FhNTQzMzI5MTBiY2M4MzU2ZDY1
14
+ OGEwYmZhY2RjZGI0Mzc0MWRjN2I2YWI0ZTQwMzI1ODVmOGI3MGRkOTZjMjlk
15
+ ZGY5ZGY2MGViYmI3NmU0NTZkNDc1MWY1NDZjOGZmMWE1YzZmZWE=
data/HISTORY.md CHANGED
@@ -1,106 +1,3 @@
1
- # 2.4.11 / 2013-01-08
1
+ # v0.0.1 / 2013-03-19
2
2
 
3
- * Numerous security issues have been fixed. Please update to `2.4.11`
4
-
5
- # 1.4.0 / 2012-04-10
6
-
7
- * Minor
8
- * Add a way to configure the `#id_prefix` property of Sanitization
9
- objects.
10
- * Add web sequence diagrams support
11
- * Support for updating wysiwyg components when markup language changes
12
- * Support RedCarpet 2.0
13
- * Allow ftp and irc links in wiki markup
14
- * Minor ui fixups
15
-
16
- * Bug Fixes
17
- * Include the language of the code snippet when making a uniquely
18
- identifiable sha of a code snippet while rendering a page.
19
- * Pygments lexer forces utf8 encoding
20
- * Remove MathJax, this created problems in production for us.
21
- We'll look at bringing it back in future releases
22
-
23
- # 1.3.1 / 2011-07-21
24
-
25
- * Major Enhancements
26
- * Allow prefixed ID attributes in headers to support internal linking
27
- (#146).
28
- * Markdown pages are rendered through Redcarpet by default (#176).
29
- * Minor Enhancements
30
- * Remove Edit button on Preview pages (#164).
31
- * Simplify Wiki#inspect and Page#inspect.
32
- * Bug Fixes
33
- * Fixed broken preview functionality (#157).
34
- * Fixed sidebar/footer rendering problems related to whitespace (#145).
35
-
36
- # 1.3.0 / 2011-04-25
37
-
38
- * Major Enhancements
39
- * Listing of all Pages
40
- * Support for running Gollum under a separate branch.
41
- * Minor Enhancements
42
- * Fix a security issue with rendering Mathjax.
43
-
44
- # 1.2.0 / 2011-03-11
45
-
46
- * Major Enhancements
47
- * Major HTML/CSS/JS overhaul.
48
- * Add Sidebars (similar to Footers).
49
- * Add commit reverts.
50
- * Minor Enhancements
51
- * Optimization in source code highlighting, resulting in a huge
52
- decrease in rendering time.
53
- * Security fixes related to source code highlighting.
54
-
55
- * Major Enhancements
56
- * Add Page sidebars, similar to Page footers.
57
- * Add the ability to revert commits to the wiki.
58
- * Add MediaWiki support.
59
- * Minor Enhancements
60
- * Add `:sanitization` and `:history_sanitization` options for customizing
61
- how `Sanitize.clean` modifies formatted wiki content.
62
- * Add `--config` option for the command line, to specify a ruby file that is
63
- run during startup.
64
- * Provide access to a parsed Nokogiri::DocumentFragment during markup
65
- rendering for added customization.
66
- * Bug Fixes
67
- * Use `@wiki.page_class` in Gollum::Markup where appropriate (#63).
68
- * Fix parsing of Org mode file links (#87).
69
-
70
- # 1.1.0 / 2010-10-28
71
-
72
- * Major Enhancements
73
- * Optimize page write/update/delete to use Grit::Index::read_tree instead
74
- of manually recreating entire index contents.
75
- * Added --irb option for the gollum command.
76
- * Update working dir (if present) when edited via the API (#6)
77
- * Add basic `git grep` based search for repos.
78
- * Minor Enhancements
79
- * Support a `:gollum_path` Sinatra setting for `Precious::App`
80
- * Add Wiki#size to efficiently count pages without loading them.
81
- * Add the correct content type when serving files from the frontend.
82
- * Add --host option and default it to 127.0.0.1.
83
- * Allow anchors in page links, such as `[[Abc#header]]`.
84
- * All pages retrieved with a SHA add `rel="nofollow"` to all
85
- page links.
86
- * Bug Fixes
87
- * Increase minimum Sanitize version requirement to 1.1.0.
88
- 1.0.x versions of Sanitize require Hpricot instead of Nokogiri
89
- and have bugs that may allow non-whitelisted HTML to sneak
90
- through.
91
- * Introduce Ruby 1.9 compatibility fixes.
92
- * Commit hashes are normalized so that missing author data is replaced with
93
- anonymous info.
94
- * Prevent `Gollum::Wiki#write_page` from clobbering existing pages.
95
- * Handle duplicate page errors in frontend.
96
- * Fix bugs trying to retrieve pages with invalid names.
97
- * CGI escape page names in links and redirects.
98
-
99
- # 1.0.1 / 2010-08-12
100
-
101
- * Bug Fixes
102
- * Force Grit dep to 2.1 or higher.
103
-
104
- # 1.0.0 / 2010-08-12
105
-
106
- * Open Source Birthday!
3
+ * First release, extrated from https://github.com/gollum/gollum
data/README.md CHANGED
@@ -1,25 +1,23 @@
1
- gollum -- A wiki built on top of Git
2
- ====================================
1
+ gollum lib -- A wiki built on top of Git
2
+ ========================================
3
3
 
4
4
  [![Build Status](https://travis-ci.org/gollum/gollum-lib.png)](https://travis-ci.org/gollum/gollum-lib)
5
5
  [![Dependency Status](https://gemnasium.com/gollum/gollum-lib.png)](https://gemnasium.com/gollum/gollum-lib)
6
6
 
7
7
  ## DESCRIPTION
8
8
 
9
- Gollum is a simple wiki system built on top of Git that powers GitHub Wikis.
9
+ [Gollum](https://github.com/gollum/gollum) is a simple wiki system built on
10
+ top of Git that powers GitHub Wikis.
10
11
 
11
- Gollum wikis are simply Git repositories that adhere to a specific format.
12
- Gollum pages may be written in a variety of formats and can be edited in a
13
- number of ways depending on your needs. You can edit your wiki locally:
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.
14
15
 
15
- * With your favorite text editor or IDE (changes will be visible after committing).
16
- * With the built-in web interface.
17
- * With the Gollum Ruby API.
18
-
19
- Gollum follows the rules of [Semantic Versioning](http://semver.org/) and uses
16
+ Gollum-lib follows the rules of [Semantic Versioning](http://semver.org/) and uses
20
17
  [TomDoc](http://tomdoc.org/) for inline documentation.
21
18
 
22
19
  ## SYSTEM REQUIREMENTS
20
+
23
21
  - Python 2.5+ (2.7.3 recommended)
24
22
  - Ruby 1.8.7+ (1.9.3 recommended)
25
23
  - Unix like operating system (OS X, Ubuntu, Debian, and more)
@@ -27,14 +25,18 @@ Gollum follows the rules of [Semantic Versioning](http://semver.org/) and uses
27
25
 
28
26
  ## INSTALLATION
29
27
 
30
- The best way to install Gollum is with RubyGems:
28
+ The best way to install Gollum-lib is with RubyGems:
31
29
 
32
- $ [sudo] gem install gollum
30
+ ```bash
31
+ $ [sudo] gem install gollum-lib
32
+ ```
33
33
 
34
34
  If you're installing from source, you can use [Bundler][bundler] to pick up all the
35
35
  gems:
36
36
 
37
- $ bundle install
37
+ ```bash
38
+ $ bundle install
39
+ ```
38
40
 
39
41
  In order to use the various formats that Gollum supports, you will need to
40
42
  separately install the necessary dependencies for each format. You only need
@@ -53,30 +55,6 @@ to install the dependencies for the formats that you plan to use.
53
55
 
54
56
  [bundler]: http://gembundler.com/
55
57
 
56
- ## RUNNING
57
-
58
- To view and edit your Gollum repository locally via the built in web
59
- interface, simply install the Gollum gem, navigate to your repository via the
60
- command line, and run the executable:
61
-
62
- $ gollum
63
-
64
- This will start up a web server running the Gollum frontend and you can view
65
- and edit your wiki at http://localhost:4567. To get help on the command line
66
- utility, you can run it like so:
67
-
68
- $ gollum --help
69
-
70
- Note that the gollum server will not run on Windows because of [an issue](https://github.com/rtomayko/posix-spawn/issues/9) with posix-spawn (which is used by Grit).
71
-
72
- ## REPO STRUCTURE
73
-
74
- A Gollum repository's contents are designed to be human editable. Page content
75
- is written in `page files` and may be organized into directories any way you
76
- choose. Special footers can be created in `footer files`. Other content
77
- (images, PDFs, etc) may also be present and organized in the same way.
78
-
79
-
80
58
  ## PAGE FILES
81
59
 
82
60
  Page files may be written in any format supported by
@@ -95,9 +73,11 @@ Gollum recognizes the following extensions:
95
73
 
96
74
  You may also register your own extensions and parsers:
97
75
 
98
- Gollum::Markup.register(:angry, "Angry") do |content|
99
- content.upcase
100
- end
76
+ ```ruby
77
+ Gollum::Markup.register(:angry, "Angry") do |content|
78
+ content.upcase
79
+ end
80
+ ```
101
81
 
102
82
  Gollum detects the page file format via the extension, so files must have one
103
83
  of the default or registered extensions in order to be converted.
@@ -116,7 +96,7 @@ automatically generated table of contents will be shown instead.
116
96
 
117
97
  ## SIDEBAR FILES
118
98
 
119
- Sidebar files allow you to add a simple sidebar to your wiki. Sidebar files
99
+ Sidebar files allow you to add a simple sidebar to your wiki. Sidebar files
120
100
  are named `_Sidebar.ext` where the extension is one of the supported formats.
121
101
  Sidebars affect all pages in their directory and any subdirectories that do not
122
102
  have a sidebar file of their own.
@@ -144,11 +124,14 @@ allowed.
144
124
 
145
125
  ## TITLES
146
126
 
147
- The first defined `h1` will override the default header on a page. There are two ways to set a page title. The metadata syntax:
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 -->
148
131
 
149
- `<!-- --- title: New Title -->`
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.
150
134
 
151
- 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.
152
135
  ## BRACKET TAGS
153
136
 
154
137
  A variety of Gollum tags use a double bracket syntax. For example:
@@ -180,8 +163,8 @@ The above tag will create a link to the corresponding page file named
180
163
  `Frodo-Baggins.ext` where `ext` may be any of the allowed extension types. The
181
164
  conversion is as follows:
182
165
 
183
- 1. Replace any spaces (U+0020) with dashes (U+002D)
184
- 2. Replace any slashes (U+002F) with dashes (U+002D)
166
+ 1. Replace any spaces (U+0020) with dashes (U+002D)
167
+ 2. Replace any slashes (U+002F) with dashes (U+002D)
185
168
 
186
169
  If you'd like the link text to be something that doesn't map directly to the
187
170
  page name, you can specify the actual page name after a pipe:
@@ -317,7 +300,7 @@ This is useful for writing about the link syntax in your wiki pages.
317
300
 
318
301
  ## TABLE OF CONTENTS
319
302
 
320
- Gollum has a special tag to insert a table of contents (new in v2.1)
303
+ Gollum has a special tag to insert a table of contents:
321
304
 
322
305
  [[_TOC_]]
323
306
 
@@ -325,12 +308,11 @@ This tag is case sensitive, use all upper case. The TOC tag can be inserted
325
308
  into the `_Header`, `_Footer` or `_Sidebar` files too.
326
309
 
327
310
  There is also a wiki option `:universal_toc` which will display a
328
- table of contents at the top of all your wiki pages if it is enabled.
329
- The `:universal_toc` is not enabled by default. To set the option,
330
- add the option to the `:wiki_options` hash before starting the
331
- frontend app:
311
+ table of contents at the top of all your wiki pages if it is enabled:
332
312
 
333
- Precious::App.set(:wiki_options, {:universal_toc => true})
313
+ ```ruby
314
+ Gollum::Wiki.new("my-gollum-repo.git", {:universal_toc => true})
315
+ ```
334
316
 
335
317
  ## SYNTAX HIGHLIGHTING
336
318
 
@@ -364,9 +346,9 @@ As an extra feature, you can syntax highlight a file from your repository, allow
364
346
  you keep some of your sample code in the main repository. The code-snippet is
365
347
  updated when the wiki is rebuilt. You include github code like this:
366
348
 
367
- ```html:gollum/gollum/master/test/file_view/1_file.txt```
349
+ ```html:github:gollum/gollum-lib/master/test/file_view/1_file.txt```
368
350
 
369
- This will make the builder look at the **github user**, in the **gollum project**,
351
+ This will make the builder look at the **gollum user**, in the **gollum-lib project**,
370
352
  in the **master branch**, at path **test/file_view/1_file.txt**. It will be
371
353
  rewritten to:
372
354
 
@@ -376,7 +358,7 @@ rewritten to:
376
358
  </ol>
377
359
  ```
378
360
 
379
- Which will be parsed as HTML code during the Pygments run, and thereby coloured
361
+ Which will be parsed as HTML code during the Pygments run, and thereby coloured
380
362
  appropriately.
381
363
 
382
364
  ## MATHEMATICAL EQUATIONS
@@ -408,161 +390,152 @@ You can replace the string "blue-modern" with any supported style.
408
390
 
409
391
  ## API DOCUMENTATION
410
392
 
411
- The Gollum API allows you to retrieve raw or formatted wiki content from a Git
412
- repository, write new content to the repository, and collect various meta data
413
- about the wiki as a whole.
414
-
415
- Initialize the Gollum::Repo object:
393
+ Initialize the `Gollum::Repo` object:
416
394
 
417
- # Require rubygems if necessary
418
- require 'rubygems'
395
+ ```ruby
396
+ # Require rubygems if necessary
397
+ require 'rubygems'
419
398
 
420
- # Require the Gollum library
421
- require 'gollum'
399
+ # Require the Gollum library
400
+ require 'gollum-lib'
422
401
 
423
- # Create a new Gollum::Wiki object by initializing it with the path to the
424
- # Git repository.
425
- wiki = Gollum::Wiki.new("my-gollum-repo.git")
426
- # => <Gollum::Wiki>
427
-
428
- By default, internal wiki links are all absolute from the root. To specify a different base path, you can specify the `:base_path` option:
429
-
430
- wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki")
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
+ ```
431
407
 
432
- Note that base_path just modifies the links. To map gollum to a non-root location:
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:
433
410
 
434
- - Use the gollum binary: `gollum path/to/wiki --base-path mywiki`
435
- - Define config.ru with `map`. See [#532](https://github.com/gollum/gollum/issues/532) for an example.
411
+ ```ruby
412
+ wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki")
413
+ ```
436
414
 
437
- > :base_path - String base path for all Wiki links.
438
- >
439
- > The String base path to prefix to internal links. For example, when set
440
- > to "/wiki", the page "Hobbit" will be linked as "/wiki/Hobbit". Defaults
441
- > to "/".
415
+ Note that `base_path` just modifies the links.
442
416
 
443
417
  Get the latest version of the given human or canonical page name:
444
418
 
445
- page = wiki.page('page-name')
446
- # => <Gollum::Page>
419
+ ```ruby
420
+ page = wiki.page('page-name')
421
+ # => <Gollum::Page>
447
422
 
448
- page.raw_data
449
- # => "# My wiki page"
423
+ page.raw_data
424
+ # => "# My wiki page"
450
425
 
451
- page.formatted_data
452
- # => "<h1>My wiki page</h1>"
426
+ page.formatted_data
427
+ # => "<h1>My wiki page</h1>"
453
428
 
454
- page.format
455
- # => :markdown
429
+ page.format
430
+ # => :markdown
456
431
 
457
- vsn = page.version
458
- # => <Grit::Commit>
432
+ vsn = page.version
433
+ # => <Grit::Commit>
459
434
 
460
- vsn.id
461
- # => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
435
+ vsn.id
436
+ # => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
437
+ ```
462
438
 
463
439
  Get the footer (if any) for a given page:
464
440
 
465
- page.footer
466
- # => <Gollum::Page>
467
-
441
+ ```ruby
442
+ page.footer
443
+ # => <Gollum::Page>
444
+ ```
445
+
468
446
  Get the header (if any) for a given page:
469
447
 
470
- page.header
471
- # => <Gollum::Page>
448
+ ```ruby
449
+ page.header
450
+ # => <Gollum::Page>
451
+ ```
472
452
 
473
453
  Get a list of versions for a given page:
474
454
 
475
- vsns = wiki.page('page-name').versions
476
- # => [<Grit::Commit, <Grit::Commit, <Grit::Commit>]
455
+ ```ruby
456
+ vsns = wiki.page('page-name').versions
457
+ # => [<Grit::Commit, <Grit::Commit, <Grit::Commit>]
477
458
 
478
- vsns.first.id
479
- # => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
459
+ vsns.first.id
460
+ # => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
480
461
 
481
- vsns.first.authored_date
482
- # => Sun Mar 28 19:11:21 -0700 2010
462
+ vsns.first.authored_date
463
+ # => Sun Mar 28 19:11:21 -0700 2010
464
+ ```
483
465
 
484
466
  Get a specific version of a given canonical page file:
485
467
 
486
- wiki.page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
468
+ ```ruby
469
+ wiki.page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
470
+ ```
487
471
 
488
472
  Get the latest version of a given static file:
489
473
 
490
- file = wiki.file('asset.js')
491
- # => <Gollum::File>
474
+ ```ruby
475
+ file = wiki.file('asset.js')
476
+ # => <Gollum::File>
492
477
 
493
- file.raw_data
494
- # => "alert('hello');"
478
+ file.raw_data
479
+ # => "alert('hello');"
495
480
 
496
- file.version
497
- # => <Grit::Commit>
481
+ file.version
482
+ # => <Grit::Commit>
483
+ ```
498
484
 
499
485
  Get a specific version of a given static file:
500
486
 
501
- wiki.file('asset.js', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
487
+ ```ruby
488
+ wiki.file('asset.js', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
489
+ ```
502
490
 
503
491
  Get an in-memory Page preview (useful for generating previews for web
504
492
  interfaces):
505
493
 
506
- preview = wiki.preview_page("My Page", "# Contents", :markdown)
507
- preview.formatted_data
508
- # => "<h1>Contents</h1>"
494
+ ```ruby
495
+ preview = wiki.preview_page("My Page", "# Contents", :markdown)
496
+ preview.formatted_data
497
+ # => "<h1>Contents</h1>"
498
+ ```
509
499
 
510
500
  Methods that write to the repository require a Hash of commit data that takes
511
501
  the following form:
512
502
 
513
- commit = { :message => 'commit message',
514
- :name => 'Tom Preston-Werner',
515
- :email => 'tom@github.com' }
503
+ ```ruby
504
+ commit = { :message => 'commit message',
505
+ :name => 'Tom Preston-Werner',
506
+ :email => 'tom@github.com' }
507
+ ```
516
508
 
517
509
  Write a new version of a page (the file will be created if it does not already
518
510
  exist) and commit the change. The file will be written at the repo root.
519
511
 
520
- wiki.write_page('Page Name', :markdown, 'Page contents', commit)
512
+ ```ruby
513
+ wiki.write_page('Page Name', :markdown, 'Page contents', commit)
514
+ ```
521
515
 
522
516
  Update an existing page. If the format is different than the page's current
523
517
  format, the file name will be changed to reflect the new format.
524
518
 
525
- page = wiki.page('Page Name')
526
- wiki.update_page(page, page.name, page.format, 'Page contents', commit)
519
+ ```ruby
520
+ page = wiki.page('Page Name')
521
+ wiki.update_page(page, page.name, page.format, 'Page contents', commit)
522
+ ```
527
523
 
528
524
  To delete a page and commit the change:
529
525
 
530
- wiki.delete_page(page, commit)
531
-
532
- ### RACK
533
-
534
- You can also run gollum with any rack-compatible server by placing this config.ru
535
- file inside your wiki repository. This allows you to utilize any Rack middleware
536
- like Rack::Auth, OmniAuth, etc.
537
-
538
- #!/usr/bin/env ruby
539
- require 'rubygems'
540
- require 'gollum/frontend/app'
541
-
542
- gollum_path = File.expand_path(File.dirname(__FILE__)) # CHANGE THIS TO POINT TO YOUR OWN WIKI REPO
543
- Precious::App.set(:gollum_path, gollum_path)
544
- Precious::App.set(:default_markup, :markdown) # set your favorite markup language
545
- Precious::App.set(:wiki_options, {:universal_toc => false})
546
- run Precious::App
547
-
548
- Your Rack middleware can pass author details to Gollum in a Hash in the session under the 'gollum.author' key.
526
+ ```ruby
527
+ wiki.delete_page(page, commit)
528
+ ```
549
529
 
550
530
  ## WINDOWS FILENAME VALIDATION
551
- 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.
552
-
553
- ## CONFIG FILE
554
-
555
- Gollum optionally takes a `--config file`. See [config.rb](https://github.com/gollum/gollum/blob/master/config.rb) for an example.
556
-
557
- ## CUSTOM CSS
558
531
 
559
- 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.
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.
560
533
 
561
534
  ## CONTRIBUTE
562
535
 
563
- If you'd like to hack on Gollum, start by forking the repo on GitHub:
536
+ If you'd like to hack on Gollum-lib, start by forking the repo on GitHub:
564
537
 
565
- http://github.com/gollum/gollum
538
+ http://github.com/gollum/gollum-lib
566
539
 
567
540
  To get all of the dependencies, install the gem first. The best way to get
568
541
  your changes merged back into core is as follows:
@@ -575,35 +548,46 @@ your changes merged back into core is as follows:
575
548
  1. Do not change the version number, I will do that on my end
576
549
  1. If necessary, rebase your commits into logical chunks, without errors
577
550
  1. Push the branch up to GitHub
578
- 1. Send a pull request to the gollum/gollum project.
551
+ 1. Send a pull request to the gollum/gollum-lib project.
579
552
 
580
553
  ## RELEASING
581
- x.y.z
582
554
 
583
- For z releases:
584
- $ rake bump
585
- $ rake release
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
+ ```
586
570
 
587
- For x.y releases:
588
- Update VERSION in lib/gollum.rb
589
- $ rake gemspec
590
- $ rake release
591
-
592
571
  ## BUILDING THE GEM FROM MASTER
593
- $ gem uninstall -aIx gollum
594
- $ git clone https://github.com/gollum/gollum.git
595
- $ cd gollum
596
- gollum$ rake build
597
- gollum$ gem install --no-ri --no-rdoc pkg/gollum*.gem
598
-
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
+
599
581
  ## RUN THE TESTS
600
582
 
601
- bundle install
602
- bundle exec rake test
583
+ ```bash
584
+ $ bundle install
585
+ $ bundle exec rake test
586
+ ```
603
587
 
604
588
  ## WORK WITH TEST REPOS
605
589
 
606
- An example of how to add a test file to the bare repository lotr.git.
590
+ An example of how to add a test file to the bare repository `lotr.git`.
607
591
 
608
592
  ```bash
609
593
  $ mkdir tmp; cd tmp
@@ -4,7 +4,7 @@ Sanitization Rules
4
4
  Gollum uses the [Sanitize](http://wonko.com/post/sanitize) gem for HTML
5
5
  sanitization.
6
6
 
7
- See `lib/gollum.rb` for actual settings.
7
+ See `lib/gollum-lib/sanitization.rb` for actual settings.
8
8
 
9
9
  ## ALLOWED TAGS
10
10
 
@@ -28,5 +28,6 @@ valign, value, vspace, width
28
28
 
29
29
  ## ALLOWED PROTOCOLS
30
30
 
31
- a href: http, https, mailto
32
- img src: http, https
31
+ a href: http, https, mailto, ftp, irc, apt
32
+ img src: http, https
33
+ form action: http, https
@@ -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-lib'
8
- s.version = '0.0.1'
9
- s.date = '2013-03-19'
8
+ s.version = '1.0.0'
9
+ s.date = '2013-04-02'
10
10
  s.rubyforge_project = 'gollum-lib'
11
11
 
12
12
  s.summary = "A simple, Git-powered wiki."
@@ -26,19 +26,20 @@ Gem::Specification.new do |s|
26
26
  s.add_dependency('github-markdown', '~> 0.5.3')
27
27
  s.add_dependency('pygments.rb', '~> 0.4.2')
28
28
  s.add_dependency('sanitize', '~> 2.0.3')
29
- s.add_dependency('nokogiri', '~> 1.5.6')
29
+ s.add_dependency('nokogiri', '~> 1.5.9')
30
30
  s.add_dependency('stringex', '~> 1.5.1')
31
31
 
32
32
  s.add_development_dependency('RedCloth', '~> 4.2.9')
33
33
  s.add_development_dependency('mocha', '~> 0.13.2')
34
34
  s.add_development_dependency('org-ruby', '~> 0.8.1')
35
- s.add_development_dependency('shoulda', '~> 3.3.2')
35
+ s.add_development_dependency('shoulda', '~> 3.4.0')
36
36
  s.add_development_dependency('wikicloth', '~> 0.8.0')
37
37
  s.add_development_dependency('rake', '~> 10.0.3')
38
38
  s.add_development_dependency('pry', '~> 0.9.12')
39
39
  # required by pry
40
40
  s.add_development_dependency('rb-readline', '~> 0.4.2')
41
- s.add_development_dependency('minitest-reporters', '>= 0.5.0')
41
+ s.add_development_dependency 'minitest-reporters', '~> 0.14.10'
42
+ s.add_development_dependency('nokogiri-diff', '~> 0.1.2')
42
43
 
43
44
  # = MANIFEST =
44
45
  s.files = %w[
@@ -47,7 +48,6 @@ Gem::Specification.new do |s|
47
48
  LICENSE
48
49
  README.md
49
50
  Rakefile
50
- config.rb
51
51
  docs/sanitization.md
52
52
  gollum-lib.gemspec
53
53
  lib/gollum-lib.rb
@@ -63,6 +63,7 @@ Gem::Specification.new do |s|
63
63
  lib/gollum-lib/markups.rb
64
64
  lib/gollum-lib/page.rb
65
65
  lib/gollum-lib/pagination.rb
66
+ lib/gollum-lib/remote_code.rb
66
67
  lib/gollum-lib/sanitization.rb
67
68
  lib/gollum-lib/web_sequence_diagram.rb
68
69
  lib/gollum-lib/wiki.rb
@@ -29,7 +29,7 @@ require File.expand_path('../gollum-lib/web_sequence_diagram', __FILE__)
29
29
  $KCODE = 'U' if RUBY_VERSION[0,3] == '1.8'
30
30
 
31
31
  module Gollum
32
- VERSION = '0.0.1'
32
+ VERSION = '1.0.0'
33
33
 
34
34
  def self.assets_path
35
35
  ::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
@@ -9,9 +9,9 @@ module Gollum
9
9
  def initialize path
10
10
  raise(ArgumentError, 'path is nil or empty') if path.nil? or path.empty?
11
11
 
12
- @uri = URI::HTTP.build({
13
- :path => self.unchomp(path),
14
- :host => 'raw.github.com',
12
+ @uri = URI::HTTP.build({
13
+ :path => self.unchomp(path),
14
+ :host => 'raw.github.com',
15
15
  :scheme => 'https',
16
16
  :port => 443 })
17
17
  end
@@ -5,7 +5,7 @@ require 'pygments'
5
5
  require 'base64'
6
6
 
7
7
  require File.expand_path '../helpers', __FILE__
8
- require File.expand_path '../gitcode', __FILE__
8
+ require File.expand_path '../remote_code', __FILE__
9
9
 
10
10
  # initialize Pygments
11
11
  Pygments.start
@@ -78,7 +78,7 @@ module Gollum
78
78
 
79
79
  data = @data.dup
80
80
  data = extract_metadata(data)
81
- data = extract_gitcode(data)
81
+ data = extract_remote_code(data)
82
82
  data = extract_code(data)
83
83
  data = extract_wsd(data)
84
84
  data = extract_tags(data)
@@ -138,7 +138,7 @@ module Gollum
138
138
  node = Nokogiri::XML::Node.new('ul', doc)
139
139
  tail = tail.add_child(node)
140
140
  tail_level += 1
141
- end
141
+ end
142
142
  while tail_level > level
143
143
  tail = tail.parent
144
144
  tail_level -= 1
@@ -457,33 +457,34 @@ module Gollum
457
457
 
458
458
  #########################################################################
459
459
  #
460
- # Gitcode - fetch code from github search path and replace the contents
461
- # to a code-block that gets run the next parse.
460
+ # Remote code - fetch code from url and replace the contents to a
461
+ # code-block that gets run the next parse.
462
462
  # Acceptable formats:
463
463
  # ```language:local-file.ext```
464
464
  # ```language:/abs/other-file.ext```
465
- # ```language:gollum/gollum/master/somefile.txt```
465
+ # ```language:https://example.com/somefile.txt```
466
466
  #
467
467
  #########################################################################
468
468
 
469
- def extract_gitcode data
470
- data.gsub /^[ \t]*``` ?([^:\n\r]+):([^`\n\r]+)```/ do
471
- contents = ''
472
- # Use empty string if $2 is nil.
473
- uri = $2 || ''
474
- # Detect local file.
475
- if uri[0..6] != 'gollum/'
476
- if file = self.find_file(uri, @wiki.ref)
477
- contents = file.raw_data
478
- else
479
- # How do we communicate a render error?
480
- next "File not found: #{CGI::escapeHTML(uri)}"
481
- end
469
+ def extract_remote_code data
470
+ data.gsub /^[ \t]*``` ?([^:\n\r]+):((http)?[^`\n\r]+)```/ do
471
+ language = $1
472
+ uri = $2
473
+ protocol = $3
474
+
475
+ # Detect local file
476
+ if protocol.nil?
477
+ if file = self.find_file(uri, @wiki.ref)
478
+ contents = file.raw_data
479
+ else
480
+ # How do we communicate a render error?
481
+ next "File not found: #{CGI::escapeHTML(uri)}"
482
+ end
482
483
  else
483
- contents = Gollum::Gitcode.new(uri).contents
484
+ contents = Gollum::RemoteCode.new(uri).contents
484
485
  end
485
486
 
486
- "```#{$1}\n#{contents}\n```\n"
487
+ "```#{language}\n#{contents}\n```\n"
487
488
  end
488
489
  end
489
490
 
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  module Gollum
2
3
  class Markup
3
4
  register(:markdown, "Markdown", :regexp => /md|mkdn?|mdown|markdown/)
@@ -10,4 +11,4 @@ module Gollum
10
11
  register(:mediawiki, "MediaWiki", :regexp => /(media)?wiki/)
11
12
  register(:pod, "Pod")
12
13
  end
13
- end
14
+ end
@@ -0,0 +1,39 @@
1
+ # ~*~ encoding: utf-8 ~*~
2
+ require 'net/http'
3
+ require 'net/https' # ruby 1.8.7 fix, remove at upgrade
4
+ require 'uri'
5
+ require 'open-uri'
6
+
7
+ module Gollum
8
+ class RemoteCode
9
+ def initialize path
10
+ raise(ArgumentError, 'path is nil or empty') if path.nil? or path.empty?
11
+ @uri = URI(path)
12
+ end
13
+
14
+ def contents
15
+ @contents ||= req @uri
16
+ end
17
+
18
+ private
19
+
20
+ def req uri, cut = 1
21
+ return "Too many redirects or retries" if cut >= 10
22
+ http = Net::HTTP.new uri.host, uri.port
23
+ http.use_ssl = true
24
+ resp = http.get uri.path, {
25
+ 'Accept' => 'text/plain',
26
+ 'Cache-Control' => 'no-cache',
27
+ 'Connection' => 'keep-alive',
28
+ 'User-Agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0'
29
+ }
30
+ code = resp.code.to_i
31
+ return resp.body if code == 200
32
+ return "Not Found" if code == 404
33
+ return "Unhandled Response Code #{code}" unless code == 304 or not resp.header['location'].nil?
34
+ loc = URI.parse resp.header['location']
35
+ uri2 = loc.relative? ? (uri + loc) : loc # overloads (+)
36
+ req uri2, (cut + 1)
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gollum-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-19 00:00:00.000000000 Z
12
+ date: 2013-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: grit
@@ -93,14 +93,14 @@ dependencies:
93
93
  requirements:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
- version: 1.5.6
96
+ version: 1.5.9
97
97
  type: :runtime
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ~>
102
102
  - !ruby/object:Gem::Version
103
- version: 1.5.6
103
+ version: 1.5.9
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: stringex
106
106
  requirement: !ruby/object:Gem::Requirement
@@ -163,14 +163,14 @@ dependencies:
163
163
  requirements:
164
164
  - - ~>
165
165
  - !ruby/object:Gem::Version
166
- version: 3.3.2
166
+ version: 3.4.0
167
167
  type: :development
168
168
  prerelease: false
169
169
  version_requirements: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ~>
172
172
  - !ruby/object:Gem::Version
173
- version: 3.3.2
173
+ version: 3.4.0
174
174
  - !ruby/object:Gem::Dependency
175
175
  name: wikicloth
176
176
  requirement: !ruby/object:Gem::Requirement
@@ -231,16 +231,30 @@ dependencies:
231
231
  name: minitest-reporters
232
232
  requirement: !ruby/object:Gem::Requirement
233
233
  requirements:
234
- - - ! '>='
234
+ - - ~>
235
235
  - !ruby/object:Gem::Version
236
- version: 0.5.0
236
+ version: 0.14.10
237
237
  type: :development
238
238
  prerelease: false
239
239
  version_requirements: !ruby/object:Gem::Requirement
240
240
  requirements:
241
- - - ! '>='
241
+ - - ~>
242
+ - !ruby/object:Gem::Version
243
+ version: 0.14.10
244
+ - !ruby/object:Gem::Dependency
245
+ name: nokogiri-diff
246
+ requirement: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - ~>
249
+ - !ruby/object:Gem::Version
250
+ version: 0.1.2
251
+ type: :development
252
+ prerelease: false
253
+ version_requirements: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ~>
242
256
  - !ruby/object:Gem::Version
243
- version: 0.5.0
257
+ version: 0.1.2
244
258
  description: A simple, Git-powered wiki with a sweet API and local frontend.
245
259
  email: tom@github.com
246
260
  executables: []
@@ -254,7 +268,6 @@ files:
254
268
  - LICENSE
255
269
  - README.md
256
270
  - Rakefile
257
- - config.rb
258
271
  - docs/sanitization.md
259
272
  - gollum-lib.gemspec
260
273
  - lib/gollum-lib.rb
@@ -270,6 +283,7 @@ files:
270
283
  - lib/gollum-lib/markups.rb
271
284
  - lib/gollum-lib/page.rb
272
285
  - lib/gollum-lib/pagination.rb
286
+ - lib/gollum-lib/remote_code.rb
273
287
  - lib/gollum-lib/sanitization.rb
274
288
  - lib/gollum-lib/web_sequence_diagram.rb
275
289
  - lib/gollum-lib/wiki.rb
data/config.rb DELETED
@@ -1,28 +0,0 @@
1
- # Example gollum config
2
- # gollum ../wiki --config config.rb
3
- #
4
- # or run from source with
5
- #
6
- # bundle exec bin/gollum ../wiki/ --config config.rb
7
-
8
- # Remove const to avoid
9
- # warning: already initialized constant FORMAT_NAMES
10
- #
11
- # only remove if it's defined.
12
- # constant Gollum::Page::FORMAT_NAMES not defined (NameError)
13
- Gollum::Page.send :remove_const, :FORMAT_NAMES if defined? Gollum::Page::FORMAT_NAMES
14
- # limit to one format
15
- Gollum::Page::FORMAT_NAMES = { :markdown => "Markdown" }
16
-
17
- =begin
18
- Valid formats are:
19
- { :markdown => "Markdown",
20
- :textile => "Textile",
21
- :rdoc => "RDoc",
22
- :org => "Org-mode",
23
- :creole => "Creole",
24
- :rest => "reStructuredText",
25
- :asciidoc => "AsciiDoc",
26
- :mediawiki => "MediaWiki",
27
- :pod => "Pod" }
28
- =end