Skip to content
Snippets Groups Projects
Commit 5b04d49e authored by Sunny Ripert's avatar Sunny Ripert
Browse files

Syntax highlighting in README

parent afeca489
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -27,12 +27,16 @@ Gollum-lib follows the rules of [Semantic Versioning](http://semver.org/) and us
 
The best way to install Gollum-lib is with RubyGems:
 
$ [sudo] gem install gollum-lib
```bash
$ [sudo] gem install gollum-lib
```
 
If you're installing from source, you can use [Bundler][bundler] to pick up all the
gems:
 
$ bundle install
```bash
$ bundle install
```
 
In order to use the various formats that Gollum supports, you will need to
separately install the necessary dependencies for each format. You only need
Loading
Loading
@@ -69,9 +73,11 @@ Gollum recognizes the following extensions:
 
You may also register your own extensions and parsers:
 
Gollum::Markup.register(:angry, "Angry") do |content|
content.upcase
end
```ruby
Gollum::Markup.register(:angry, "Angry") do |content|
content.upcase
end
```
 
Gollum detects the page file format via the extension, so files must have one
of the default or registered extensions in order to be converted.
Loading
Loading
@@ -155,8 +161,8 @@ The above tag will create a link to the corresponding page file named
`Frodo-Baggins.ext` where `ext` may be any of the allowed extension types. The
conversion is as follows:
 
1. Replace any spaces (U+0020) with dashes (U+002D)
2. Replace any slashes (U+002F) with dashes (U+002D)
1. Replace any spaces (U+0020) with dashes (U+002D)
2. Replace any slashes (U+002F) with dashes (U+002D)
 
If you'd like the link text to be something that doesn't map directly to the
page name, you can specify the actual page name after a pipe:
Loading
Loading
@@ -302,7 +308,9 @@ into the `_Header`, `_Footer` or `_Sidebar` files too.
There is also a wiki option `:universal_toc` which will display a
table of contents at the top of all your wiki pages if it is enabled:
 
Gollum::Wiki.new("my-gollum-repo.git", {:universal_toc => true})
```ruby
Gollum::Wiki.new("my-gollum-repo.git", {:universal_toc => true})
```
 
## SYNTAX HIGHLIGHTING
 
Loading
Loading
@@ -382,113 +390,140 @@ You can replace the string "blue-modern" with any supported style.
 
Initialize the `Gollum::Repo` object:
 
# Require rubygems if necessary
require 'rubygems'
```ruby
# Require rubygems if necessary
require 'rubygems'
 
# Require the Gollum library
require 'gollum-lib'
# Require the Gollum library
require 'gollum-lib'
 
# Create a new Gollum::Wiki object by initializing it with the path to the
# Git repository.
wiki = Gollum::Wiki.new("my-gollum-repo.git")
# => <Gollum::Wiki>
# Create a new Gollum::Wiki object by initializing it with the path to the
# Git repository.
wiki = Gollum::Wiki.new("my-gollum-repo.git")
# => <Gollum::Wiki>
```
 
By default, internal wiki links are all absolute from the root. To specify a different
base path, you can specify the `:base_path` option:
 
wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki")
```ruby
wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki")
```
 
Note that base_path just modifies the links.
Note that `base_path` just modifies the links.
 
Get the latest version of the given human or canonical page name:
 
page = wiki.page('page-name')
# => <Gollum::Page>
```ruby
page = wiki.page('page-name')
# => <Gollum::Page>
 
page.raw_data
# => "# My wiki page"
page.raw_data
# => "# My wiki page"
 
page.formatted_data
# => "<h1>My wiki page</h1>"
page.formatted_data
# => "<h1>My wiki page</h1>"
 
page.format
# => :markdown
page.format
# => :markdown
 
vsn = page.version
# => <Grit::Commit>
vsn = page.version
# => <Grit::Commit>
 
vsn.id
# => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
vsn.id
# => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
```
 
Get the footer (if any) for a given page:
 
page.footer
# => <Gollum::Page>
```ruby
page.footer
# => <Gollum::Page>
```
 
Get the header (if any) for a given page:
 
page.header
# => <Gollum::Page>
```ruby
page.header
# => <Gollum::Page>
```
 
Get a list of versions for a given page:
 
vsns = wiki.page('page-name').versions
# => [<Grit::Commit, <Grit::Commit, <Grit::Commit>]
```ruby
vsns = wiki.page('page-name').versions
# => [<Grit::Commit, <Grit::Commit, <Grit::Commit>]
 
vsns.first.id
# => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
vsns.first.id
# => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
 
vsns.first.authored_date
# => Sun Mar 28 19:11:21 -0700 2010
vsns.first.authored_date
# => Sun Mar 28 19:11:21 -0700 2010
```
 
Get a specific version of a given canonical page file:
 
wiki.page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
```ruby
wiki.page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
```
 
Get the latest version of a given static file:
 
file = wiki.file('asset.js')
# => <Gollum::File>
```ruby
file = wiki.file('asset.js')
# => <Gollum::File>
 
file.raw_data
# => "alert('hello');"
file.raw_data
# => "alert('hello');"
 
file.version
# => <Grit::Commit>
file.version
# => <Grit::Commit>
```
 
Get a specific version of a given static file:
 
wiki.file('asset.js', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
```ruby
wiki.file('asset.js', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
```
 
Get an in-memory Page preview (useful for generating previews for web
interfaces):
 
preview = wiki.preview_page("My Page", "# Contents", :markdown)
preview.formatted_data
# => "<h1>Contents</h1>"
```ruby
preview = wiki.preview_page("My Page", "# Contents", :markdown)
preview.formatted_data
# => "<h1>Contents</h1>"
```
 
Methods that write to the repository require a Hash of commit data that takes
the following form:
 
commit = { :message => 'commit message',
:name => 'Tom Preston-Werner',
:email => 'tom@github.com' }
```ruby
commit = { :message => 'commit message',
:name => 'Tom Preston-Werner',
:email => 'tom@github.com' }
```
 
Write a new version of a page (the file will be created if it does not already
exist) and commit the change. The file will be written at the repo root.
 
wiki.write_page('Page Name', :markdown, 'Page contents', commit)
```ruby
wiki.write_page('Page Name', :markdown, 'Page contents', commit)
```
 
Update an existing page. If the format is different than the page's current
format, the file name will be changed to reflect the new format.
 
page = wiki.page('Page Name')
wiki.update_page(page, page.name, page.format, 'Page contents', commit)
```ruby
page = wiki.page('Page Name')
wiki.update_page(page, page.name, page.format, 'Page contents', commit)
```
 
To delete a page and commit the change:
 
wiki.delete_page(page, commit)
```ruby
wiki.delete_page(page, commit)
```
 
## WINDOWS FILENAME VALIDATION
 
Loading
Loading
@@ -515,32 +550,38 @@ your changes merged back into core is as follows:
 
## RELEASING
 
Gollum-lib uses [Semantic Versioning](http://semver.org/).
x.y.z
Gollum-lib uses [Semantic Versioning](http://semver.org/). Having `x.y.z` :
 
For z releases:
 
$ rake bump
$ rake release
```bash
$ rake bump
$ rake release
```
 
For x.y releases:
 
$ rake gemspec
$ rake release
```bash
$ rake gemspec
$ rake release
```
 
## BUILDING THE GEM FROM MASTER
 
$ gem uninstall -aIx gollum-lib
$ git clone https://github.com/gollum/gollum-lib.git
$ cd gollum-lib
gollum-lib$ rake build
gollum-lib$ gem install --no-ri --no-rdoc pkg/gollum-lib*.gem
```bash
$ gem uninstall -aIx gollum-lib
$ git clone https://github.com/gollum/gollum-lib.git
$ cd gollum-lib
gollum-lib$ rake build
gollum-lib$ gem install --no-ri --no-rdoc pkg/gollum-lib*.gem
```
 
## RUN THE TESTS
 
$ bundle install
$ bundle exec rake test
```bash
$ bundle install
$ bundle exec rake test
```
 
## WORK WITH TEST REPOS
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment