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