Syntax highlighting in README
This commit is contained in:
@@ -35,12 +35,16 @@ A better solution with more security is being tracked in [#665](https://github.c
|
|||||||
|
|
||||||
The best way to install Gollum is with RubyGems:
|
The best way to install Gollum is with RubyGems:
|
||||||
|
|
||||||
$ [sudo] gem install gollum
|
```bash
|
||||||
|
$ [sudo] gem install gollum
|
||||||
|
```
|
||||||
|
|
||||||
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
|
||||||
@@ -65,13 +69,17 @@ To view and edit your Gollum repository locally via the built in web
|
|||||||
interface, simply install the Gollum gem, navigate to your repository via the
|
interface, simply install the Gollum gem, navigate to your repository via the
|
||||||
command line, and run the executable:
|
command line, and run the executable:
|
||||||
|
|
||||||
$ gollum
|
```bash
|
||||||
|
$ gollum
|
||||||
|
```
|
||||||
|
|
||||||
This will start up a web server running the Gollum frontend and you can view
|
This will start up a web server running the Gollum frontend and you can view
|
||||||
and edit your wiki at http://localhost:4567. To get help on the command line
|
and edit your wiki at http://localhost:4567. To get help on the command line
|
||||||
utility, you can run it like so:
|
utility, you can run it like so:
|
||||||
|
|
||||||
$ gollum --help
|
```bash
|
||||||
|
$ gollum --help
|
||||||
|
```
|
||||||
|
|
||||||
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).
|
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).
|
||||||
|
|
||||||
@@ -82,7 +90,6 @@ is written in `page files` and may be organized into directories any way you
|
|||||||
choose. Special footers can be created in `footer files`. Other content
|
choose. Special footers can be created in `footer files`. Other content
|
||||||
(images, PDFs, etc) may also be present and organized in the same way.
|
(images, PDFs, etc) may also be present and organized in the same way.
|
||||||
|
|
||||||
|
|
||||||
## PAGE FILES
|
## PAGE FILES
|
||||||
|
|
||||||
Page files may be written in any format supported by
|
Page files may be written in any format supported by
|
||||||
@@ -101,9 +108,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.
|
||||||
@@ -150,11 +159,13 @@ allowed.
|
|||||||
|
|
||||||
## TITLES
|
## TITLES
|
||||||
|
|
||||||
The first defined `h1` will override the default header on a page. There are two ways to set a page title. The metadata syntax:
|
The first defined `h1` will override the default header on a page. There are
|
||||||
|
two ways to set a page title. The metadata syntax:
|
||||||
|
|
||||||
`<!-- --- title: New Title -->`
|
<!-- --- title: New Title -->
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
## BRACKET TAGS
|
## BRACKET TAGS
|
||||||
|
|
||||||
@@ -187,8 +198,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:
|
||||||
@@ -337,7 +348,9 @@ The `:universal_toc` is not enabled by default. To set the option,
|
|||||||
add the option to the `:wiki_options` hash before starting the
|
add the option to the `:wiki_options` hash before starting the
|
||||||
frontend app:
|
frontend app:
|
||||||
|
|
||||||
Precious::App.set(:wiki_options, {:universal_toc => true})
|
```ruby
|
||||||
|
Precious::App.set(:wiki_options, {:universal_toc => true})
|
||||||
|
```
|
||||||
|
|
||||||
## SYNTAX HIGHLIGHTING
|
## SYNTAX HIGHLIGHTING
|
||||||
|
|
||||||
@@ -420,21 +433,25 @@ repository, and collect various meta data about the wiki as a whole.
|
|||||||
|
|
||||||
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. To map gollum to a non-root location:
|
Note that base_path just modifies the links. To map gollum to a non-root location:
|
||||||
|
|
||||||
@@ -449,92 +466,116 @@ Note that base_path just modifies the links. To map gollum to a non-root locatio
|
|||||||
|
|
||||||
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)
|
||||||
|
```
|
||||||
|
|
||||||
### RACK
|
### RACK
|
||||||
|
|
||||||
@@ -542,15 +583,17 @@ You can also run gollum with any rack-compatible server by placing this config.r
|
|||||||
file inside your wiki repository. This allows you to utilize any Rack middleware
|
file inside your wiki repository. This allows you to utilize any Rack middleware
|
||||||
like Rack::Auth, OmniAuth, etc.
|
like Rack::Auth, OmniAuth, etc.
|
||||||
|
|
||||||
#!/usr/bin/env ruby
|
```ruby
|
||||||
require 'rubygems'
|
#!/usr/bin/env ruby
|
||||||
require 'gollum/frontend/app'
|
require 'rubygems'
|
||||||
|
require 'gollum/frontend/app'
|
||||||
|
|
||||||
gollum_path = File.expand_path(File.dirname(__FILE__)) # CHANGE THIS TO POINT TO YOUR OWN WIKI REPO
|
gollum_path = File.expand_path(File.dirname(__FILE__)) # CHANGE THIS TO POINT TO YOUR OWN WIKI REPO
|
||||||
Precious::App.set(:gollum_path, gollum_path)
|
Precious::App.set(:gollum_path, gollum_path)
|
||||||
Precious::App.set(:default_markup, :markdown) # set your favorite markup language
|
Precious::App.set(:default_markup, :markdown) # set your favorite markup language
|
||||||
Precious::App.set(:wiki_options, {:universal_toc => false})
|
Precious::App.set(:wiki_options, {:universal_toc => false})
|
||||||
run Precious::App
|
run Precious::App
|
||||||
|
```
|
||||||
|
|
||||||
Your Rack middleware can pass author details to Gollum in a Hash in the session under the 'gollum.author' key.
|
Your Rack middleware can pass author details to Gollum in a Hash in the session under the 'gollum.author' key.
|
||||||
|
|
||||||
@@ -595,26 +638,35 @@ Gollum uses [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
For z releases:
|
For z releases:
|
||||||
|
|
||||||
$ rake bump
|
```bash
|
||||||
$ rake release
|
$ rake bump
|
||||||
|
$ rake release
|
||||||
|
```
|
||||||
|
|
||||||
For x.y releases:
|
For x.y releases:
|
||||||
|
|
||||||
Update VERSION in lib/gollum.rb
|
```bash
|
||||||
$ rake gemspec
|
Update VERSION in lib/gollum.rb
|
||||||
$ rake release
|
$ rake gemspec
|
||||||
|
$ rake release
|
||||||
|
```
|
||||||
|
|
||||||
## BUILDING THE GEM FROM MASTER
|
## BUILDING THE GEM FROM MASTER
|
||||||
$ gem uninstall -aIx gollum
|
|
||||||
$ git clone https://github.com/gollum/gollum.git
|
```bash
|
||||||
$ cd gollum
|
$ gem uninstall -aIx gollum
|
||||||
gollum$ rake build
|
$ git clone https://github.com/gollum/gollum.git
|
||||||
gollum$ gem install --no-ri --no-rdoc pkg/gollum*.gem
|
$ cd gollum
|
||||||
|
gollum$ rake build
|
||||||
|
gollum$ gem install --no-ri --no-rdoc pkg/gollum*.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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user