benjamin wil 95d35d38da Switch from TestUnit to Minitest (#1805)
* Use `Minitest::Test`

`Test::Unit` is deprecated, and we can switch to `Minitest::Test` with
almost no side effects.

This commit does all of the work required to make Minitest tests run
with Gollum's existing test helpers.

* Change Minitest output format

- The `DefaultReporter` seems to have cleaner output than what we had
  before.
- `color: true` ensures things are colorized. It's pretty nice.

* Tweak test formatting; fix order-dependent failure

The order-dependent failure has been been commented in code.

After manually bisecting the test suite, I was able to determine that
the template cascade tests were leaving the `@@template_priority_path`
set to an overridden value in tests run afterward.

* Tweak setting initialization

I could not see a meaningful reason behind calling `forbid` so early in
the settings initialization block. But moving the `forbid` call until
later resolved this issue.

In the real world, I don't see how this would cause issues. But I found
that calling `forbid` when `wiki_options[:allow_editing]` was set to
false caused order-dependent test errors where Sprockets would end up
being badly configured and left without an initialized
`Sprockets::Environment` object, which is required by the
`sprockets-helpers` gem to resolve asset paths.

The test that would cause errors is also in this commit diff. I've
updated it to be a bit more readable.

I also took this opportunity to review and clean up the `@allow_editing`
assignment, which seemed a bit obfuscated.

* Update migration script to test run warnings

When running the entire test suite, many warnings would be output:

/Users/bw/Projects/gollum/test/test_migrate.rb:37: warning: already initialized constant HYPHENATE
/Users/bw/Projects/gollum/test/test_migrate.rb:37: warning: previous definition of HYPHENATE was here
/Users/bw/Projects/gollum/test/test_migrate.rb:37: warning: already initialized constant PAGE_FILE_DIR
/Users/bw/Projects/gollum/test/test_migrate.rb:37: warning: previous definition of PAGE_FILE_DIR was here
/Users/bw/Projects/gollum/bin/gollum-migrate-tags:91: warning: already initialized constant REPO
/Users/bw/Projects/gollum/bin/gollum-migrate-tags:91: warning: previous definition of REPO was here
/Users/bw/Projects/gollum/bin/gollum-migrate-tags:236: warning: already initialized constant TREE
/Users/bw/Projects/gollum/bin/gollum-migrate-tags:236: warning: previous definition of TREE was here
/Users/bw/Projects/gollum/test/test_migrate.rb:37: warning: already initialized constant PAGE_FILE_DIR
/Users/bw/Projects/gollum/test/test_migrate.rb:37: warning: previous definition of PAGE_FILE_DIR was here
/Users/bw/Projects/gollum/bin/gollum-migrate-tags:91: warning: already initialized constant REPO
/Users/bw/Projects/gollum/bin/gollum-migrate-tags:91: warning: previous definition of REPO was here
/Users/bw/Projects/gollum/bin/gollum-migrate-tags:236: warning: already initialized constant TREE
/Users/bw/Projects/gollum/bin/gollum-migrate-tags:236: warning: previous definition of TREE was here

While it's unlikely that end users would ever see these warnings, as
they'd only be running the migration script once, they will always be
shown in our local test runs and CI run output.

So instead of using constants in our migration script, I change the
script to use class variables instead. This should not effect the
functionality of the migration script whatsoever.

* Use `File.exist?` instead of `File.exists?`

In Ruby 3.x, `File.exists?` is deprecated and outputs a warning.

* Improve "allow editing" tests

While making changes to the test suite, I ran into some issues with
these tests failing on occasion.

I added some setup and teardown to help with this.

But one thing I did notice is that the word "Upload" appears in the
response body whether uploading is enabled or not, so I made these
assertions more specific to the HTML rather than other places the word
"Upload" might appear (which is related to Critic Markup).

* Do not attempt to modify frozen strings

Using `#gsub!` here now results in an error. I am not entirely sure why
this hasn't happened before, but the error is straightforward:

     FrozenError: can't modify frozen String: "Author %{author} is from %{location}"
        /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:45:in `gsub!'
        /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:45:in `fill_argument_content'
        /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:37:in `block in autofill'
        /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:33:in `each'
        /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:33:in `map'
        /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:33:in `autofill'
        /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:35:in `block in autofill'
        /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:33:in `each'
        /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:33:in `map'
        /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:33:in `autofill'
        /home/runner/work/gollum/gollum/lib/gollum/views/helpers/locale_helpers.rb:21:in `t'
        /home/runner/work/gollum/gollum/test/gollum/views/test_locale_helper.rb:95:in `block (4 levels) in <top (required)>'

`#gsub!` attempts to modify a string in-place, which does not work when
a string is frozen. It seems that in some Ruby environments, strings
from YAML files are frozen.

* Fix another order-dependent test failure

Very occasionally, this test fails due to `Precious::App` settings set
in previous tests. You can reproduce this failure using this seed:

    bundle exec rake TESTOPTS="--seed=42898"
2022-04-27 08:25:54 -07:00
2018-09-24 18:40:08 +02:00
2015-08-12 22:26:20 +02:00
2015-08-12 22:26:20 +02:00
2021-02-26 11:34:41 +01:00
2021-04-18 13:43:00 +02:00
2020-03-24 15:55:28 +01:00

gollum -- A git-based Wiki

Gem Version Build Status Open Source Helpers Cutting Edge Dependency Status

Gollum version 5.0 is out! See here for a list of changes and new features compared to Gollum version 4.x, and see some Screenshots of Gollum's features.

DESCRIPTION

Gollum is a simple wiki system built on top of Git. A Gollum Wiki is simply a git repository of a specific nature:

  • A Gollum repository's contents are human-editable text or markup files.
  • Pages may be organized into directories any way you choose.
  • Other content can also be included, for example images, PDFs and headers/footers for your pages.
  • Gollum pages:
    • May be written in a variety of markups.
    • Can be edited with your favourite system editor or IDE (changes will be visible after committing) or with the built-in web interface.
    • Can be displayed in all versions, reverted, etc.
  • Gollum strives to be compatible with GitHub wikis (see --lenient-tag-lookup)
  • Gollum supports advanced functionality like:

SYSTEM REQUIREMENTS

Gollum runs on Unix-like systems using its adapter for rugged by default. You can also run Gollum on JRuby via its adapter for RJGit. On Windows, Gollum runs only on JRuby.

INSTALLATION

  1. Ruby is best installed either via RVM or a package manager of choice.
  2. Gollum is best installed via RubyGems:
    [sudo] gem install gollum
    

Installation examples for individual systems can be seen here.

To run, simply:

  1. Run: gollum /path/to/wiki where /path/to/wiki is an initialized Git repository.
  2. Open http://localhost:4567 in your browser.

See below for information on running Gollum from source, as a Rack app, and more.

Markups

Gollum allows using different markup languages on different wiki pages. It presently ships with support for the following markups:

You can easily activate support for other markups by installing additional renderers (any that are supported by github-markup):

  • AsciiDoc -- [sudo] gem install asciidoctor
  • Creole -- [sudo] gem install creole
  • MediaWiki -- [sudo] gem install wikicloth
  • Org -- [sudo] gem install org-ruby
  • Pod -- requires Perl >= 5.10 (the perl command must be available on your command line)
    • Lower versions should install Pod::Simple from CPAN.
  • ReStructuredText -- requires python >= 2 (the python2 command must be available on your command line)
    • Note that Gollum will also need you to install docutils for your Python 2.
  • Textile -- [sudo] gem install RedCloth

Markdown flavors

By default, Gollum ships with the kramdown gem to render Markdown. However, you can use any Markdown renderer supported by github-markup. This includes CommonMark support via the commonmarker gem. The first installed renderer from the list will be used (e.g., redcarpet will NOT be used if github/markdown is installed). Just gem install the renderer of your choice.

See here for instructions on how to use custom rendering gems and set custom options.

RUNNING FROM SOURCE

  1. git clone https://github.com/gollum/gollum
  2. cd gollum
  3. [sudo] bundle install
  4. bundle exec bin/gollum
  5. Open http://localhost:4567 in your browser.

Rack

Gollum can also be run with any rack-compatible web server. More on that over here.

Rack, with an authentication server

Gollum can also be run alongside a CAS (Central Authentication Service) SSO (single sign-on) server. With a bit of tweaking, this adds basic user-support to Gollum. To see an example and an explanation, navigate over here.

Docker

Gollum can also be run via Docker. More on that over here.

Service

Gollum can also be run as a service. More on that over here.

CONFIGURATION

Gollum comes with the following command line options:

Option Arguments Description
--host [HOST] Specify the hostname or IP address to listen on. Default: '0.0.0.0'.1
--port [PORT] Specify the port to bind Gollum with. Default: 4567.
--config [FILE] Specify path to Gollum's configuration file.
--ref [REF] Specify the git branch to serve. Default: master.
--bare none Tell Gollum that the git repository should be treated as bare.
--adapter [ADAPTER] Launch Gollum using a specific git adapter. Default: rugged.2
--base-path [PATH] Specify the leading portion of all Gollum URLs (path info). Setting this to /wiki will make the wiki accessible under http://localhost:4567/wiki/. Default: /.
--page-file-dir [PATH] Specify the subdirectory for all pages. If set, Gollum will only serve pages from this directory and its subdirectories. Default: repository root.
--static, --no-static none Use static assets. Defaults to false in development/test, true in production/staging.
--assets [PATH] Set the path to look for static assets.
--css none Tell Gollum to inject custom CSS into each page. Uses custom.css from wiki root.3
--js none Tell Gollum to inject custom JS into each page. Uses custom.js from wiki root.3
--no-edit none Disable the feature of editing pages.
--local-time none Use the browser's local timezone instead of the server's for displaying dates. Default: false.
--follow-renames, --no-follow-renames none Follow pages across renames in the History view. Default: true.
--allow-uploads [MODE] Enable file uploads. If set to dir, Gollum will store all uploads in the /uploads/ directory in repository root. If set to page, Gollum will store each upload at the currently edited page.4
--mathjax none Enables MathJax (renders mathematical equations). By default, uses the TeX-AMS-MML_HTMLorMML config with the autoload-all extension.5
--critic-markup none Enable support for annotations using CriticMarkup.
--irb none Launch Gollum in "console mode", with a predefined API.
--h1-title none Tell Gollum to use the first <h1> as page title.
--no-display-metadata none Do not render metadata tables in pages.
--user-icons [MODE] Tell Gollum to use specific user icons for history view. Can be set to gravatar, identicon or none. Default: none.
--mathjax-config [FILE] Specify path to a custom MathJax configuration. If not specified, uses the mathjax.config.js file from repository root.
--template-dir [PATH] Specify custom mustache template directory. Only overrides templates that exist in this directory.
--template-page none Use _Template in root as a template for new pages. Must be committed.
--emoji none Parse and interpret emoji tags (e.g. :heart:) except when the leading colon is backslashed (e.g. \:heart:).
--lenient-tag-lookup none Internal links resolve case-insensitively, will treat spaces as hyphens, and will match the first page found with a certain filename, anywhere in the repository. Provides compatibility with Gollum 4.x.
--help none Display the list of options on the command line.
--version none Display the current version of Gollum.
--versions none Display the current version of Gollum and auxiliary gems.

Notes:

  1. The 0.0.0.0 IP address allows remote access. Should you wish for Gollum to turn into a personal Wiki, use 127.0.0.1.
  2. Before using --adapter, you should probably read this first.
  3. When --css or --js is used, respective files must be committed to your git repository or you will get a 302 redirect to the create a page.
  4. Files can be uploaded simply by dragging and dropping them onto the editor's text area when --allow-uploads is used.

Config file

When --config option is used, certain inner parts of Gollum can be customized. This is used throughout our wiki for certain user-level alterations, among which customizing supported markups will probably stand out.

All of the mentioned alterations work both for Gollum's config file (config.rb) and Rack's config file (config.ru).

CONTRIBUTING

Please consider helping out! See CONTRIBUTING for information on how to submit issues, and how to start hacking on gollum.

THANKS TO

Testing Powered By SauceLabs

S
Description
Source for Gollum instance at https://wiki.ohea.xyz
Readme 18 MiB
Languages
JavaScript 88.9%
Ruby 8.3%
Shell 0.9%
Mustache 0.8%
SCSS 0.7%
Other 0.3%