Syntax highlighting in README

This commit is contained in:
Sunny Ripert
2013-03-22 13:18:30 +01:00
parent 4e04f5f540
commit ea3544f46d
+56 -4
View File
@@ -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:
```bash
$ [sudo] gem install gollum $ [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:
```bash
$ bundle install $ 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:
```bash
$ gollum $ 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:
```bash
$ gollum --help $ 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:
```ruby
Gollum::Markup.register(:angry, "Angry") do |content| Gollum::Markup.register(:angry, "Angry") do |content|
content.upcase content.upcase
end 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
@@ -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:
```ruby
Precious::App.set(:wiki_options, {:universal_toc => true}) Precious::App.set(:wiki_options, {:universal_toc => true})
```
## SYNTAX HIGHLIGHTING ## SYNTAX HIGHLIGHTING
@@ -420,6 +433,7 @@ repository, and collect various meta data about the wiki as a whole.
Initialize the `Gollum::Repo` object: Initialize the `Gollum::Repo` object:
```ruby
# Require rubygems if necessary # Require rubygems if necessary
require 'rubygems' require 'rubygems'
@@ -430,11 +444,14 @@ Initialize the `Gollum::Repo` object:
# 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:
```ruby
wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki") 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,6 +466,7 @@ 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:
```ruby
page = wiki.page('page-name') page = wiki.page('page-name')
# => <Gollum::Page> # => <Gollum::Page>
@@ -466,19 +484,25 @@ Get the latest version of the given human or canonical page name:
vsn.id vsn.id
# => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5' # => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'
```
Get the footer (if any) for a given page: Get the footer (if any) for a given page:
```ruby
page.footer page.footer
# => <Gollum::Page> # => <Gollum::Page>
```
Get the header (if any) for a given page: Get the header (if any) for a given page:
```ruby
page.header page.header
# => <Gollum::Page> # => <Gollum::Page>
```
Get a list of versions for a given page: Get a list of versions for a given page:
```ruby
vsns = wiki.page('page-name').versions vsns = wiki.page('page-name').versions
# => [<Grit::Commit, <Grit::Commit, <Grit::Commit>] # => [<Grit::Commit, <Grit::Commit, <Grit::Commit>]
@@ -487,13 +511,17 @@ Get a list of versions for a given page:
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:
```ruby
wiki.page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a') wiki.page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')
```
Get the latest version of a given static file: Get the latest version of a given static file:
```ruby
file = wiki.file('asset.js') file = wiki.file('asset.js')
# => <Gollum::File> # => <Gollum::File>
@@ -502,39 +530,52 @@ Get the latest version of a given static file:
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:
```ruby
wiki.file('asset.js', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a') 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):
```ruby
preview = wiki.preview_page("My Page", "# Contents", :markdown) preview = wiki.preview_page("My Page", "# Contents", :markdown)
preview.formatted_data preview.formatted_data
# => "<h1>Contents</h1>" # => "<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:
```ruby
commit = { :message => 'commit message', commit = { :message => 'commit message',
:name => 'Tom Preston-Werner', :name => 'Tom Preston-Werner',
:email => 'tom@github.com' } :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.
```ruby
wiki.write_page('Page Name', :markdown, 'Page contents', commit) 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.
```ruby
page = wiki.page('Page Name') page = wiki.page('Page Name')
wiki.update_page(page, page.name, page.format, 'Page contents', commit) 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:
```ruby
wiki.delete_page(page, commit) wiki.delete_page(page, commit)
```
### RACK ### RACK
@@ -542,6 +583,7 @@ 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.
```ruby
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'rubygems' require 'rubygems'
require 'gollum/frontend/app' require 'gollum/frontend/app'
@@ -551,6 +593,7 @@ like Rack::Auth, OmniAuth, etc.
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:
```bash
$ rake bump $ rake bump
$ rake release $ rake release
```
For x.y releases: For x.y releases:
```bash
Update VERSION in lib/gollum.rb Update VERSION in lib/gollum.rb
$ rake gemspec $ rake gemspec
$ rake release $ rake release
```
## BUILDING THE GEM FROM MASTER ## BUILDING THE GEM FROM MASTER
```bash
$ gem uninstall -aIx gollum $ gem uninstall -aIx gollum
$ git clone https://github.com/gollum/gollum.git $ git clone https://github.com/gollum/gollum.git
$ cd gollum $ cd gollum
gollum$ rake build gollum$ rake build
gollum$ gem install --no-ri --no-rdoc pkg/gollum*.gem gollum$ gem install --no-ri --no-rdoc pkg/gollum*.gem
```
## RUN THE TESTS ## RUN THE TESTS
```bash
$ bundle install $ bundle install
$ bundle exec rake test $ bundle exec rake test
```
## WORK WITH TEST REPOS ## WORK WITH TEST REPOS