README.md in gollum-lib-0.0.1 vs README.md in gollum-lib-1.0.0

- old
+ new

@@ -1,42 +1,44 @@ -gollum -- A wiki built on top of Git -==================================== +gollum lib -- A wiki built on top of Git +======================================== [![Build Status](https://travis-ci.org/gollum/gollum-lib.png)](https://travis-ci.org/gollum/gollum-lib) [![Dependency Status](https://gemnasium.com/gollum/gollum-lib.png)](https://gemnasium.com/gollum/gollum-lib) ## DESCRIPTION -Gollum is a simple wiki system built on top of Git that powers GitHub Wikis. +[Gollum](https://github.com/gollum/gollum) is a simple wiki system built on +top of Git that powers GitHub Wikis. -Gollum wikis are simply Git repositories that adhere to a specific format. -Gollum pages may be written in a variety of formats and can be edited in a -number of ways depending on your needs. You can edit your wiki locally: +Gollum-lib is the Ruby API that allows you to retrieve raw or formatted wiki +content from a Git repository, write new content to the repository, and collect +various meta data about the wiki as a whole. -* With your favorite text editor or IDE (changes will be visible after committing). -* With the built-in web interface. -* With the Gollum Ruby API. - -Gollum follows the rules of [Semantic Versioning](http://semver.org/) and uses +Gollum-lib follows the rules of [Semantic Versioning](http://semver.org/) and uses [TomDoc](http://tomdoc.org/) for inline documentation. ## SYSTEM REQUIREMENTS + - Python 2.5+ (2.7.3 recommended) - Ruby 1.8.7+ (1.9.3 recommended) - Unix like operating system (OS X, Ubuntu, Debian, and more) - Will not work on Windows (because of [grit](https://github.com/github/grit)) ## INSTALLATION -The best way to install Gollum is with RubyGems: +The best way to install Gollum-lib is with RubyGems: - $ [sudo] gem install gollum +```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 to install the dependencies for the formats that you plan to use. @@ -51,34 +53,10 @@ * [Textile](http://www.textism.com/tools/textile/) -- `gem install RedCloth` * [MediaWiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `gem install wikicloth` [bundler]: http://gembundler.com/ -## RUNNING - -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 -command line, and run the executable: - - $ gollum - -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 -utility, you can run it like so: - - $ 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). - -## REPO STRUCTURE - -A Gollum repository's contents are designed to be human editable. Page content -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 -(images, PDFs, etc) may also be present and organized in the same way. - - ## PAGE FILES Page files may be written in any format supported by [GitHub-Markup](http://github.com/github/markup) (except roff). By default, Gollum recognizes the following extensions: @@ -93,13 +71,15 @@ * Textile: .textile * MediaWiki: .mediawiki, .wiki 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. Page file names may contain any printable UTF-8 character except space @@ -114,11 +94,11 @@ formats) will be used as the entrance page to your wiki. If it is missing, an automatically generated table of contents will be shown instead. ## SIDEBAR FILES -Sidebar files allow you to add a simple sidebar to your wiki. Sidebar files +Sidebar files allow you to add a simple sidebar to your wiki. Sidebar files are named `_Sidebar.ext` where the extension is one of the supported formats. Sidebars affect all pages in their directory and any subdirectories that do not have a sidebar file of their own. ## HEADER FILES @@ -142,15 +122,18 @@ `docs/sanitization.md` for more details on what tags and attributes are allowed. ## 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 A variety of Gollum tags use a double bracket syntax. For example: [[Link]] @@ -178,12 +161,12 @@ 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: [[Frodo|Frodo Baggins]] @@ -315,24 +298,23 @@ This is useful for writing about the link syntax in your wiki pages. ## TABLE OF CONTENTS -Gollum has a special tag to insert a table of contents (new in v2.1) +Gollum has a special tag to insert a table of contents: [[_TOC_]] This tag is case sensitive, use all upper case. The TOC tag can be inserted 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. -The `:universal_toc` is not enabled by default. To set the option, -add the option to the `:wiki_options` hash before starting the -frontend app: +table of contents at the top of all your wiki pages if it is enabled: - Precious::App.set(:wiki_options, {:universal_toc => true}) +```ruby +Gollum::Wiki.new("my-gollum-repo.git", {:universal_toc => true}) +``` ## SYNTAX HIGHLIGHTING In page files you can get automatic syntax highlighting for a wide range of languages (courtesy of [Pygments](http://pygments.org/) - must install @@ -362,23 +344,23 @@ As an extra feature, you can syntax highlight a file from your repository, allowing you keep some of your sample code in the main repository. The code-snippet is updated when the wiki is rebuilt. You include github code like this: - ```html:gollum/gollum/master/test/file_view/1_file.txt``` + ```html:github:gollum/gollum-lib/master/test/file_view/1_file.txt``` -This will make the builder look at the **github user**, in the **gollum project**, +This will make the builder look at the **gollum user**, in the **gollum-lib project**, in the **master branch**, at path **test/file_view/1_file.txt**. It will be rewritten to: ```html <ol class="tree"> <li class="file"><a href="0">0</a></li> </ol> ``` -Which will be parsed as HTML code during the Pygments run, and thereby coloured +Which will be parsed as HTML code during the Pygments run, and thereby coloured appropriately. ## MATHEMATICAL EQUATIONS Start gollum with the `--mathjax` flag. Read more about [MathJax](http://docs.mathjax.org/en/latest/index.html) on the web. Gollum uses the `TeX-AMS-MML_HTMLorMML` config with the `autoload-all` extension. @@ -406,165 +388,156 @@ You can replace the string "blue-modern" with any supported style. ## API DOCUMENTATION -The Gollum API allows you to retrieve raw or formatted wiki content from a Git -repository, write new content to the 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' - # Require rubygems if necessary - require 'rubygems' +# Require the Gollum library +require 'gollum-lib' - # Require the Gollum library - require 'gollum' +# 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: -By default, internal wiki links are all absolute from the root. To specify a different 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. -Note that base_path just modifies the links. To map gollum to a non-root location: - -- Use the gollum binary: `gollum path/to/wiki --base-path mywiki` -- Define config.ru with `map`. See [#532](https://github.com/gollum/gollum/issues/532) for an example. - -> :base_path - String base path for all Wiki links. -> -> The String base path to prefix to internal links. For example, when set -> to "/wiki", the page "Hobbit" will be linked as "/wiki/Hobbit". Defaults -> to "/". - 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) +``` -### RACK - -You can also run gollum with any rack-compatible server by placing this config.ru -file inside your wiki repository. This allows you to utilize any Rack middleware -like Rack::Auth, OmniAuth, etc. - - #!/usr/bin/env ruby - require 'rubygems' - require 'gollum/frontend/app' - - 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(:default_markup, :markdown) # set your favorite markup language - Precious::App.set(:wiki_options, {:universal_toc => false}) - run Precious::App - -Your Rack middleware can pass author details to Gollum in a Hash in the session under the 'gollum.author' key. - ## WINDOWS FILENAME VALIDATION + 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. -## CONFIG FILE - -Gollum optionally takes a `--config file`. See [config.rb](https://github.com/gollum/gollum/blob/master/config.rb) for an example. - -## CUSTOM CSS - -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. - ## CONTRIBUTE -If you'd like to hack on Gollum, start by forking the repo on GitHub: +If you'd like to hack on Gollum-lib, start by forking the repo on GitHub: -http://github.com/gollum/gollum +http://github.com/gollum/gollum-lib To get all of the dependencies, install the gem first. The best way to get your changes merged back into core is as follows: 1. Clone down your fork @@ -573,38 +546,49 @@ 1. Add tests and make sure everything still passes by running `rake` 1. If you are adding new functionality, document it in the README 1. Do not change the version number, I will do that on my end 1. If necessary, rebase your commits into logical chunks, without errors 1. Push the branch up to GitHub -1. Send a pull request to the gollum/gollum project. +1. Send a pull request to the gollum/gollum-lib project. ## RELEASING - x.y.z - For z releases: - $ rake bump - $ rake release +Gollum-lib uses [Semantic Versioning](http://semver.org/). Having `x.y.z` : - For x.y releases: - Update VERSION in lib/gollum.rb - $ rake gemspec - $ rake release - +For z releases: + +```bash +$ rake bump +$ rake release +``` + +For x.y releases: + +```bash +$ rake gemspec +$ rake release +``` + ## BUILDING THE GEM FROM MASTER - $ gem uninstall -aIx gollum - $ git clone https://github.com/gollum/gollum.git - $ cd gollum - gollum$ rake build - gollum$ gem install --no-ri --no-rdoc pkg/gollum*.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 -An example of how to add a test file to the bare repository lotr.git. +An example of how to add a test file to the bare repository `lotr.git`. ```bash $ mkdir tmp; cd tmp $ git clone ../lotr.git/ . Cloning into '.'...