Compare commits

..

9 Commits

Author SHA1 Message Date
benjamin wil b035e3cd26 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-02-21 14:13:17 -08:00
benjamin wil 63edb3e8c4 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.
2022-02-20 15:39:05 -08:00
benjamin wil e4f549a9b9 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).
2022-02-20 15:39:05 -08:00
benjamin wil 1641fa4e90 Use File.exist? instead of File.exists?
In Ruby 3.x, `File.exists?` is deprecated and outputs a warning.
2022-02-20 15:39:05 -08:00
benjamin wil 0b18f475f0 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.
2022-02-20 15:39:05 -08:00
benjamin wil f5c8af9904 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.
2022-02-20 15:39:05 -08:00
benjamin wil 7a019567ec 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.
2022-02-20 15:39:04 -08:00
benjamin wil 675fff02ac 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.
2022-02-20 11:19:22 -08:00
benjamin wil 0364d6e1be 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.
2022-02-20 11:18:54 -08:00
19 changed files with 116 additions and 329 deletions
-1
View File
@@ -45,6 +45,5 @@ jobs:
tags: ${{ env.DEPLOY_NAME }} tags: ${{ env.DEPLOY_NAME }}
cache-from: type=local,src=/tmp/.buildx-cache cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64, linux/arm64
- name: Image digest - name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }} run: echo ${{ steps.docker_build.outputs.digest }}
+3 -4
View File
@@ -19,8 +19,7 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with: with:
tag_name: ${{ github.ref_name }} tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref_name }} release_name: Release ${{ github.ref }}
draft: true draft: false
prerelease: false prerelease: false
body_path: "LATEST_CHANGES.md"
+1 -1
View File
@@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
ruby: ['2.6', '2.7', '3.0', '3.1'] ruby: [2.6, 2.7, 3.0]
steps: steps:
- name: Check out repository code - name: Check out repository code
uses: actions/checkout@v2 uses: actions/checkout@v2
+1 -2
View File
@@ -32,8 +32,7 @@ COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
RUN apk add \ RUN apk add \
bash \ bash \
git \ git
libc6-compat
VOLUME /wiki VOLUME /wiki
WORKDIR /wiki WORKDIR /wiki
+3 -16
View File
@@ -1,25 +1,12 @@
# 5.3.0 / 2022-05-25 # 5.2.3 2021-04-18
* Feature: allow for overriding only specific Mustache templates/partials (@beporter)
* Feature: Add option to show browser's local time (@NikitaIvanovV)
* Improvement: presentation on mobile devises (@benjaminwil)
* Improvement: Add page context to template filter. #1603 (@tevino)
* Fix: restore normalize check on file upload (@manofstick)
* Fix mathjax on edit and create pages. #1772 (@fhchl)
* Fix utf-8 issues: #1721 #1758 #1801 (@basking2, @dometto)
* Fix an IME rendering issue. #1735 (@yy0931)
* Fix broken history button when viewing historical deleted file. (@NikitaIvanovV)
* Fix: non-ascii characters in page names are not rendered correctly in the preview tab of the "Edit" page. #1739 (@yy0931)
* Fix: anchors and header display on JRuby. #1779
# 5.2.3 / 2021-04-18
* Fix bug preventing page titles from being displayed * Fix bug preventing page titles from being displayed
# 5.2.1 / 2021-02-25 # 5.2.1 2021-02-25
* Fix include call to a missing asset (@benjaminwil). This caused slow first page loads on JRuby. * Fix include call to a missing asset (@benjaminwil). This caused slow first page loads on JRuby.
# 5.2 / 2021-02-24 # 5.2 2021-02-24
* Improved styling and Primer upgrade (@benjaminwil) * Improved styling and Primer upgrade (@benjaminwil)
* Add redirect to rename commit (@ViChyavIn) * Add redirect to rename commit (@ViChyavIn)
-13
View File
@@ -1,13 +0,0 @@
# 5.3.0 / 2022-05-24
* Feature: allow for overriding only specific Mustache templates/partials (@beporter)
* Feature: Add option to show browser's local time (@NikitaIvanovV)
* Improvement: presentation on mobile devises (@benjaminwil)
* Improvement: Add page context to template filter. #1603 (@tevino)
* Fix: restore normalize check on file upload (@manofstick)
* Fix mathjax on edit and create pages. #1772 (@fhchl)
* Fix utf-8 issues: #1721 #1758 #1801 (@basking2, @dometto)
* Fix an IME rendering issue. #1735 (@yy0931)
* Fix broken history button when viewing historical deleted file. (@NikitaIvanovV)
* Fix: non-ascii characters in page names are not rendered correctly in the preview tab of the "Edit" page. #1739 (@yy0931)
* Fix: anchors and header display on JRuby. #1779
+23 -29
View File
@@ -5,24 +5,21 @@ gollum -- A git-based Wiki
![Build Status](https://github.com/gollum/gollum/actions/workflows/test.yaml/badge.svg) ![Build Status](https://github.com/gollum/gollum/actions/workflows/test.yaml/badge.svg)
[![Open Source Helpers](https://www.codetriage.com/gollum/gollum/badges/users.svg)](https://www.codetriage.com/gollum/gollum) [![Open Source Helpers](https://www.codetriage.com/gollum/gollum/badges/users.svg)](https://www.codetriage.com/gollum/gollum)
[![Cutting Edge Dependency Status](https://dometto-cuttingedge.herokuapp.com/github/gollum/gollum/svg 'Cutting Edge Dependency Status')](https://dometto-cuttingedge.herokuapp.com/github/gollum/gollum/info) [![Cutting Edge Dependency Status](https://dometto-cuttingedge.herokuapp.com/github/gollum/gollum/svg 'Cutting Edge Dependency Status')](https://dometto-cuttingedge.herokuapp.com/github/gollum/gollum/info)
[![Docker Pulls](https://img.shields.io/docker/pulls/gollumwiki/gollum)](https://hub.docker.com/r/gollumwiki/gollum)
See the [wiki](https://github.com/gollum/gollum/wiki) for extensive documentation, along with [screenshots](https://github.com/gollum/gollum/wiki/Screenshots) of Gollum's features.
**Gollum version 5.0 is out!** See [here](https://github.com/gollum/gollum/wiki/5.0-release-notes) for a list of changes and new features compared to Gollum version 4.x, and see some [Screenshots](https://github.com/gollum/gollum/wiki/Screenshots) of Gollum's features.
## DESCRIPTION ## DESCRIPTION
Gollum is a simple wiki system built on top of Git. A Gollum Wiki is simply a git repository of a specific nature: 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. * A Gollum repository's contents are human-editable text or markup files.
* Pages may be organized into directories any way you choose. * 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. * Other content can also be included, for example images, PDFs and headers/footers for your pages.
* Gollum pages: * Gollum pages:
* May be written in a variety of [markups](#markups). * May be written in a variety of [markups](#markups).
* Can be edited with your favourite editor (changes will be visible after committing) or with the built-in web interface. * 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. * Can be displayed in all versions, reverted, etc.
* Gollum strives to be [compatible](https://github.com/gollum/gollum/wiki/5.0-release-notes#compatibility-option) with [GitHub](https://docs.github.com/en/communities/documenting-your-project-with-wikis/about-wikis) and [GitLab](https://docs.gitlab.com/ee/user/project/wiki/#create-or-edit-wiki-pages-locally) wikis. * Gollum strives to be compatible with GitHub wikis (see `--lenient-tag-lookup`)
* Just clone your GitHub/GitLab wiki and view and edit it locally!
* Gollum supports advanced functionality like: * Gollum supports advanced functionality like:
* [UML diagrams](https://github.com/gollum/gollum/wiki#plantuml-diagrams) * [UML diagrams](https://github.com/gollum/gollum/wiki#plantuml-diagrams)
* [BibTeX and Citation support](https://github.com/gollum/gollum/wiki/BibTeX-and-Citations) * [BibTeX and Citation support](https://github.com/gollum/gollum/wiki/BibTeX-and-Citations)
@@ -35,17 +32,16 @@ Gollum is a simple wiki system built on top of Git. A Gollum Wiki is simply a gi
### SYSTEM REQUIREMENTS ### SYSTEM REQUIREMENTS
Gollum runs on Unix-like systems using its default [adapter](https://github.com/gollum/rugged_adapter) for [rugged](https://github.com/libgit2/rugged). You can also run Gollum on [JRuby](https://github.com/jruby/jruby) via its [adapter](https://github.com/repotag/gollum-lib_rjgit_adapter) for [RJGit](https://github.com/repotag/rjgit/). On Windows, Gollum runs only on JRuby. Gollum runs on Unix-like systems using its [adapter](https://github.com/gollum/rugged_adapter) for [rugged](https://github.com/libgit2/rugged) by default. You can also run Gollum on [JRuby](https://github.com/jruby/jruby) via its [adapter](https://github.com/repotag/gollum-lib_rjgit_adapter) for [RJGit](https://github.com/repotag/rjgit/). On Windows, Gollum runs only on JRuby.
## INSTALLATION ## INSTALLATION
### As a Ruby Gem 1. Ruby is best installed either via [RVM](https://rvm.io/) or a package manager of choice.
2. Gollum is best installed via RubyGems:
```
[sudo] gem install gollum
```
Ruby is best installed either via [RVM](https://rvm.io/) or a package manager of choice. Then simply:
```
gem install gollum
```
Installation examples for individual systems can be seen [here](https://github.com/gollum/gollum/wiki/Installation). Installation examples for individual systems can be seen [here](https://github.com/gollum/gollum/wiki/Installation).
To run, simply: To run, simply:
@@ -53,30 +49,24 @@ To run, simply:
1. Run: `gollum /path/to/wiki` where `/path/to/wiki` is an initialized Git repository. 1. Run: `gollum /path/to/wiki` where `/path/to/wiki` is an initialized Git repository.
2. Open `http://localhost:4567` in your browser. 2. Open `http://localhost:4567` in your browser.
### Via Docker
See [here](https://github.com/gollum/gollum/wiki/Gollum-via-Docker) for instructions on how to run Gollum via Docker.
### Misc
See [below](#running-from-source) for information on running Gollum from source, as a Rack app, and more. See [below](#running-from-source) for information on running Gollum from source, as a Rack app, and more.
## MARKUPS ### Markups
Gollum allows using different markup languages on different wiki pages. It presently ships with support for the following markups: Gollum allows using different markup languages on different wiki pages. It presently ships with support for the following markups:
* [Markdown](http://daringfireball.net/projects/markdown/syntax) (see [below](#Markdown-flavors) for more information on Markdown flavors) * [Markdown](http://daringfireball.net/projects/markdown/syntax) (see [below](#Markdown-flavors) for more information on Markdown flavors)
* [RDoc](http://rdoc.sourceforge.net/) * [RDoc](http://rdoc.sourceforge.net/)
You can easily activate support for other markups by installing additional renderers (any that are supported by [github-markup](https://github.com/github/markup)): You can easily activate support for other markups by installing additional renderers (any that are supported by [github-markup](https://github.com/github/markup)):
* [AsciiDoc](http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/) -- `gem install asciidoctor` * [AsciiDoc](http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/) -- `[sudo] gem install asciidoctor`
* [Creole](http://www.wikicreole.org/wiki/CheatSheet) -- `gem install creole` * [Creole](http://www.wikicreole.org/wiki/CheatSheet) -- `[sudo] gem install creole`
* [MediaWiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `gem install wikicloth` * [MediaWiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `[sudo] gem install wikicloth`
* [Org](http://orgmode.org/worg/dev/org-syntax.html) -- `gem install org-ruby` * [Org](http://orgmode.org/worg/dev/org-syntax.html) -- `[sudo] gem install org-ruby`
* [Pod](http://perldoc.perl.org/perlpod.html) -- requires Perl >= 5.10 (the `perl` command must be available on your command line) * [Pod](http://perldoc.perl.org/perlpod.html) -- requires Perl >= 5.10 (the `perl` command must be available on your command line)
* Lower versions should install `Pod::Simple` from CPAN. * Lower versions should install `Pod::Simple` from CPAN.
* [ReStructuredText](http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html) -- requires python >= 3 * [ReStructuredText](http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html) -- requires python >= 2 (the `python2` command must be available on your command line)
* Note that Gollum will also need you to install `docutils` for python * Note that Gollum will also need you to install `docutils` for your Python 2.
* [Textile](http://redcloth.org/hobix.com/textile/quick.html) -- `gem install RedCloth` * [Textile](http://redcloth.org/hobix.com/textile/quick.html) -- `[sudo] gem install RedCloth`
### Markdown flavors ### Markdown flavors
@@ -100,6 +90,10 @@ Gollum can also be run with any [rack-compatible web server](https://github.com/
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](https://github.com/gollum/gollum/wiki/Gollum-via-Rack-and-CAS-SSO). 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](https://github.com/gollum/gollum/wiki/Gollum-via-Rack-and-CAS-SSO).
### Docker
Gollum can also be run via [Docker](https://www.docker.com/). More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-via-Docker).
### Service ### Service
Gollum can also be run as a service. More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-as-a-service). Gollum can also be run as a service. More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-as-a-service).
@@ -112,7 +106,7 @@ Gollum comes with the following command line options:
| ----------------- | --------- | ----------- | | ----------------- | --------- | ----------- |
| --host | [HOST] | Specify the hostname or IP address to listen on. Default: '0.0.0.0'.<sup>1</sup> | | --host | [HOST] | Specify the hostname or IP address to listen on. Default: '0.0.0.0'.<sup>1</sup> |
| --port | [PORT] | Specify the port to bind Gollum with. Default: `4567`. | | --port | [PORT] | Specify the port to bind Gollum with. Default: `4567`. |
| --config | [FILE] | Specify path to Gollum's [configuration file](#Config-file). | | --config | [FILE] | Specify path to Gollum's configuration file. |
| --ref | [REF] | Specify the git branch to serve. Default: `master`. | | --ref | [REF] | Specify the git branch to serve. Default: `master`. |
| --bare | none | Tell Gollum that the git repository should be treated as bare. | | --bare | none | Tell Gollum that the git repository should be treated as bare. |
| --adapter | [ADAPTER] | Launch Gollum using a specific git adapter. Default: `rugged`.<sup>2</sup> | | --adapter | [ADAPTER] | Launch Gollum using a specific git adapter. Default: `rugged`.<sup>2</sup> |
+12 -55
View File
@@ -1,7 +1,6 @@
require 'rubygems' require 'rubygems'
require 'rake' require 'rake'
require 'date' require 'date'
require 'tempfile'
############################################################################# #############################################################################
# #
@@ -9,10 +8,6 @@ require 'tempfile'
# #
############################################################################# #############################################################################
def date
Time.now.strftime("%Y-%m-%d")
end
def name def name
@name ||= Dir['*.gemspec'].first.split('.').first @name ||= Dir['*.gemspec'].first.split('.').first
end end
@@ -22,14 +17,6 @@ def version
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1] line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
end end
def latest_changes_file
'LATEST_CHANGES.md'
end
def history_file
'HISTORY.md'
end
# assumes x.y.z all digit version # assumes x.y.z all digit version
def next_version def next_version
# x.y.z # x.y.z
@@ -51,6 +38,14 @@ def bump_version
new_version new_version
end end
def date
Date.today.to_s
end
def rubyforge_project
name
end
def gemspec_file def gemspec_file
"#{name}.gemspec" "#{name}.gemspec"
end end
@@ -119,7 +114,6 @@ task :release => :build do
puts "You must be on the master branch to release!" puts "You must be on the master branch to release!"
exit! exit!
end end
Rake::Task[:changelog].execute
sh "git commit --allow-empty -a -m 'Release #{version}'" sh "git commit --allow-empty -a -m 'Release #{version}'"
sh "git pull --rebase origin master" sh "git pull --rebase origin master"
sh "git tag v#{version}" sh "git tag v#{version}"
@@ -149,9 +143,12 @@ task :gemspec => :validate do
spec = File.read(gemspec_file) spec = File.read(gemspec_file)
head, manifest, tail = spec.split(" # = MANIFEST =\n") head, manifest, tail = spec.split(" # = MANIFEST =\n")
# replace name and version # replace name version and date
replace_header(head, :name) replace_header(head, :name)
replace_header(head, :version) replace_header(head, :version)
replace_header(head, :date)
#comment this out if your rubyforge_project has a different name
replace_header(head, :rubyforge_project)
# determine file list from git ls-files # determine file list from git ls-files
files = `git ls-files`. files = `git ls-files`.
@@ -182,46 +179,6 @@ task :validate do
end end
end end
desc 'Build changlog'
task :changelog do
[latest_changes_file, history_file].each do |f|
unless File.exists?(f)
puts "#{f} does not exist but is required to build a new release."
exit!
end
end
latest_changes = File.open(latest_changes_file)
version_pattern = "# #{version}"
if !`grep "#{version_pattern}" #{history_file}`.empty?
puts "#{version} is already described in #{history_file}"
exit!
end
begin
unless latest_changes.readline.chomp! =~ %r{#{version_pattern}}
puts "#{latest_changes_file} should begin with '#{version_pattern}'"
exit!
end
rescue EOFError
puts "#{latest_changes_file} is empty!"
exit!
end
body = latest_changes.read
body.scan(/\s*#\s+\d\.\d.*/) do |match|
puts "#{latest_changes_file} may not contain multiple markdown headers!"
exit!
end
temp = Tempfile.new
temp.puts("#{version_pattern} / #{date}\n#{body}\n")
temp.close
`cat #{history_file} >> #{temp.path}`
`cat #{temp.path} > #{history_file}`
end
desc 'Precompile assets' desc 'Precompile assets'
task :precompile do task :precompile do
require './lib/gollum/app.rb' require './lib/gollum/app.rb'
+11 -16
View File
@@ -1,9 +1,12 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.specification_version = 2 if s.respond_to? :specification_version=
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version= s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
s.rubygems_version = '1.3.5'
s.required_ruby_version = '>= 2.6' s.required_ruby_version = '>= 2.6'
s.name = 'gollum' s.name = 'gollum'
s.version = '5.3.0' s.version = '5.2.3'
s.date = '2021-04-18'
s.license = 'MIT' s.license = 'MIT'
s.summary = 'A simple, Git-powered wiki.' s.summary = 'A simple, Git-powered wiki.'
@@ -20,7 +23,6 @@ Gem::Specification.new do |s|
s.rdoc_options = ['--charset=UTF-8'] s.rdoc_options = ['--charset=UTF-8']
s.extra_rdoc_files = %w[README.md LICENSE] s.extra_rdoc_files = %w[README.md LICENSE]
s.add_dependency 'rdoc', '~> 6'
s.add_dependency 'gollum-lib', '~> 5.1' s.add_dependency 'gollum-lib', '~> 5.1'
s.add_dependency 'kramdown', '~> 2.3' s.add_dependency 'kramdown', '~> 2.3'
s.add_dependency 'kramdown-parser-gfm', '~> 1.1.0' s.add_dependency 'kramdown-parser-gfm', '~> 1.1.0'
@@ -48,10 +50,8 @@ Gem::Specification.new do |s|
# = MANIFEST = # = MANIFEST =
s.files = %w[ s.files = %w[
CONTRIBUTING.md CONTRIBUTING.md
Dockerfile
Gemfile Gemfile
HISTORY.md HISTORY.md
LATEST_CHANGES.md
LICENSE LICENSE
README.md README.md
Rakefile Rakefile
@@ -64,21 +64,20 @@ Gem::Specification.new do |s|
contrib/openrc/init.d/gollum contrib/openrc/init.d/gollum
contrib/systemd/gollum@.service contrib/systemd/gollum@.service
contrib/sysv-debian/init.d/gollum contrib/sysv-debian/init.d/gollum
docker-run.sh
gollum.gemspec gollum.gemspec
lib/gollum.rb lib/gollum.rb
lib/gollum/app.rb lib/gollum/app.rb
lib/gollum/assets.rb lib/gollum/assets.rb
lib/gollum/helpers.rb lib/gollum/helpers.rb
lib/gollum/public/assets/.sprockets-manifest-160337b312f8e438181baac4aaa37319.json lib/gollum/public/assets/.sprockets-manifest-de7bb79aec424e55af1acdcc4237b301.json
lib/gollum/public/assets/app-309be032396e783b13a47df58f389b7c8e11c2b2d42640560b874f677c25f6e5.css lib/gollum/public/assets/app-0fd228e26bfbe6fe31a2da268eb0e98e780c1191c1a918adf383377946e9c838.js
lib/gollum/public/assets/app-309be032396e783b13a47df58f389b7c8e11c2b2d42640560b874f677c25f6e5.css.gz lib/gollum/public/assets/app-0fd228e26bfbe6fe31a2da268eb0e98e780c1191c1a918adf383377946e9c838.js.gz
lib/gollum/public/assets/app-f05401ee374f0c7f48fc2bc08e30b4f4db705861fd5895ed70998683b383bfb5.js lib/gollum/public/assets/app-ad43ca64b295d8444b10f22ee868f18429268af498f1bc515434878b690e37a2.css
lib/gollum/public/assets/app-f05401ee374f0c7f48fc2bc08e30b4f4db705861fd5895ed70998683b383bfb5.js.gz lib/gollum/public/assets/app-ad43ca64b295d8444b10f22ee868f18429268af498f1bc515434878b690e37a2.css.gz
lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css
lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css.gz lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css.gz
lib/gollum/public/assets/editor-9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a.js lib/gollum/public/assets/editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js
lib/gollum/public/assets/editor-9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a.js.gz lib/gollum/public/assets/editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js.gz
lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css
lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css.gz lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css.gz
lib/gollum/public/gollum/javascript/HOWTO_UPDATE_ACE.md lib/gollum/public/gollum/javascript/HOWTO_UPDATE_ACE.md
@@ -1212,7 +1211,6 @@ Gem::Specification.new do |s|
lib/gollum/templates/pagination.mustache lib/gollum/templates/pagination.mustache
lib/gollum/templates/search.mustache lib/gollum/templates/search.mustache
lib/gollum/templates/searchbar.mustache lib/gollum/templates/searchbar.mustache
lib/gollum/templates/user.mustache
lib/gollum/templates/wiki_content.mustache lib/gollum/templates/wiki_content.mustache
lib/gollum/uri_encode_component.rb lib/gollum/uri_encode_component.rb
lib/gollum/views/commit.rb lib/gollum/views/commit.rb
@@ -1221,11 +1219,9 @@ Gem::Specification.new do |s|
lib/gollum/views/edit.rb lib/gollum/views/edit.rb
lib/gollum/views/editable.rb lib/gollum/views/editable.rb
lib/gollum/views/error.rb lib/gollum/views/error.rb
lib/gollum/views/has_math.rb
lib/gollum/views/has_page.rb lib/gollum/views/has_page.rb
lib/gollum/views/has_user_icons.rb lib/gollum/views/has_user_icons.rb
lib/gollum/views/helpers.rb lib/gollum/views/helpers.rb
lib/gollum/views/helpers/locale_helpers.rb
lib/gollum/views/history.rb lib/gollum/views/history.rb
lib/gollum/views/latest_changes.rb lib/gollum/views/latest_changes.rb
lib/gollum/views/layout.rb lib/gollum/views/layout.rb
@@ -1234,7 +1230,6 @@ Gem::Specification.new do |s|
lib/gollum/views/pagination.rb lib/gollum/views/pagination.rb
lib/gollum/views/rss.rb lib/gollum/views/rss.rb
lib/gollum/views/search.rb lib/gollum/views/search.rb
lib/gollum/views/template_cascade.rb
licenses/licenses.txt licenses/licenses.txt
] ]
# = MANIFEST = # = MANIFEST =
+3 -4
View File
@@ -13,7 +13,7 @@ require 'rhino' if RUBY_PLATFORM == 'java'
require ::File.expand_path('../gollum/uri_encode_component', __FILE__) require ::File.expand_path('../gollum/uri_encode_component', __FILE__)
module Gollum module Gollum
VERSION = '5.3.0' VERSION = '5.2.3'
::I18n.available_locales = [:en] ::I18n.available_locales = [:en]
::I18n.load_path = Dir[::File.expand_path("lib/gollum/locales") + "/*.yml"] ::I18n.load_path = Dir[::File.expand_path("lib/gollum/locales") + "/*.yml"]
@@ -29,10 +29,9 @@ module Gollum
@@filters[pattern] = replacement @@filters[pattern] = replacement
end end
def self.apply_filters(wiki_page, data) def self.apply_filters(data)
@@filters.each do |pattern, replacement| @@filters.each do |pattern, replacement|
params = replacement.parameters.length == 0 ? nil : wiki_page data.gsub!(pattern, replacement.call)
data.gsub!(pattern, replacement.call(*params))
end end
data data
end end
+7 -52
View File
@@ -211,7 +211,7 @@ module Precious
end end
get '/edit/*' do get '/edit/*' do
forbid unless @allow_editing && @user_authed forbid unless @allow_editing
wikip = wiki_page(params[:splat].first) wikip = wiki_page(params[:splat].first)
@name = wikip.fullname @name = wikip.fullname
@path = wikip.path @path = wikip.path
@@ -234,7 +234,6 @@ module Precious
wiki = wiki_new wiki = wiki_new
halt 405 unless wiki.allow_uploads halt 405 unless wiki.allow_uploads
forbid unless @user_authed
if params[:file] if params[:file]
fullname = params[:file][:filename] fullname = params[:file][:filename]
@@ -274,7 +273,7 @@ module Precious
options.merge! author options.merge! author
end end
options[:normalize] = Gollum::Page.valid_extension?(fullname) normalize = Gollum::Page.valid_extension?(fullname)
begin begin
wiki.write_file(reponame, contents, options) wiki.write_file(reponame, contents, options)
@@ -291,7 +290,6 @@ module Precious
post '/rename/*' do post '/rename/*' do
wikip = wiki_page(params[:splat].first) wikip = wiki_page(params[:splat].first)
halt 500 if wikip.nil? halt 500 if wikip.nil?
forbid unless @user_authed
wiki = wikip.wiki wiki = wikip.wiki
page = wikip.page page = wikip.page
rename = params[:rename] rename = params[:rename]
@@ -335,7 +333,6 @@ module Precious
path = "/#{clean_url(sanitize_empty_params(params[:path]))}" path = "/#{clean_url(sanitize_empty_params(params[:path]))}"
wiki = wiki_new wiki = wiki_new
page = wiki.page(::File.join(path, params[:page])) page = wiki.page(::File.join(path, params[:page]))
forbid unless @user_authed
return if page.nil? return if page.nil?
if etag != page.sha if etag != page.sha
@@ -356,7 +353,6 @@ module Precious
post '/delete/*' do post '/delete/*' do
forbid unless @allow_editing forbid unless @allow_editing
forbid unless @user_authed
wiki = wiki_new wiki = wiki_new
filepath = params[:splat].first filepath = params[:splat].first
unless filepath.nil? unless filepath.nil?
@@ -368,12 +364,11 @@ module Precious
get '/create/*' do get '/create/*' do
forbid unless @allow_editing forbid unless @allow_editing
forbid unless @user_authed
wikip = wiki_page(params[:splat].first) wikip = wiki_page(params[:splat].first)
@name = wikip.name @name = wikip.name
@ext = wikip.ext @ext = wikip.ext
@path = wikip.path @path = wikip.path
@template_page = load_template(wikip, @path) if settings.wiki_options[:template_page] @template_page = load_template(@path) if settings.wiki_options[:template_page]
@allow_uploads = wikip.wiki.allow_uploads @allow_uploads = wikip.wiki.allow_uploads
@upload_dest = find_upload_dest(wikip.fullpath) @upload_dest = find_upload_dest(wikip.fullpath)
@@ -394,7 +389,6 @@ module Precious
path = sanitize_empty_params(params[:path]) || '' path = sanitize_empty_params(params[:path]) || ''
format = params[:format].intern format = params[:format].intern
wiki = wiki_new wiki = wiki_new
forbid unless @user_authed
path.gsub!(/^\//, '') path.gsub!(/^\//, '')
@@ -626,41 +620,7 @@ module Precious
def show_page_or_file(fullpath) def show_page_or_file(fullpath)
wiki = wiki_new wiki = wiki_new
if page = wiki.page(fullpath)
# check if folders exists
contents = wiki.tree_list
print contents
entry = contents.detect do |entry|
Gollum::File::path_match(fullpath, entry)
end
print entry
#if path
# @path = Pathname.new(path).cleanpath.to_s
# check_path = wiki.page_file_dir ? ::File.join(wiki.page_file_dir, @path, '/') : "#{@path}/"
# @results.select! {|result| result.path.start_with?(check_path) }
#end
#@results.sort_by! {|result| result.name.downcase}
#elsif fullpath[-1] == '/' ? Gollum::Page.valid_page_name?(fullpath) : false
if page = fullpath[-1] != '/' ? wiki.page("#{fullpath}/#{wiki.index_page}") : false
@page = page
@name = page.filename_stripped
@content = page.formatted_data
@upload_dest = find_upload_dest(Pathname.new(fullpath).cleanpath.to_s)
# Extensions and layout data
@editable = true
@toc_content = wiki.universal_toc ? @page.toc_data : nil
@h1_title = wiki.h1_title
@bar_side = wiki.bar_side
@allow_uploads = wiki.allow_uploads
@navbar = true
mustache :page
elsif page = wiki.page(fullpath)
@page = page @page = page
@name = page.filename_stripped @name = page.filename_stripped
@content = page.formatted_data @content = page.formatted_data
@@ -678,13 +638,8 @@ module Precious
show_file(file) show_file(file)
elsif @redirects_enabled && redirect_path = wiki.redirects[fullpath] elsif @redirects_enabled && redirect_path = wiki.redirects[fullpath]
redirect to("#{encodeURIComponent(redirect_path)}?redirected_from=#{encodeURIComponent(fullpath)}") redirect to("#{encodeURIComponent(redirect_path)}?redirected_from=#{encodeURIComponent(fullpath)}")
elsif entry
# check if the folder fullpath exists
# if so, redirect to overview
#
redirect to("/gollum/overview/#{clean_url(encodeURIComponent(fullpath))}")
else else
if @allow_editing && @user_authed if @allow_editing
path = fullpath[-1] == '/' ? "#{fullpath}#{wiki.index_page}" : fullpath # Append default index page if no page name is supplied path = fullpath[-1] == '/' ? "#{fullpath}#{wiki.index_page}" : fullpath # Append default index page if no page name is supplied
redirect to("/gollum/create/#{clean_url(encodeURIComponent(path))}") redirect to("/gollum/create/#{clean_url(encodeURIComponent(path))}")
else else
@@ -705,9 +660,9 @@ module Precious
end end
end end
def load_template(wiki_page, path) def load_template(path)
template_page = wiki_page(::File.join(path, '_Template')).page || wiki_page('/_Template').page template_page = wiki_page(::File.join(path, '_Template')).page || wiki_page('/_Template').page
template_page ? Gollum::TemplateFilter.apply_filters(wiki_page, template_page.text_data) : nil template_page ? Gollum::TemplateFilter.apply_filters(template_page.text_data) : nil
end end
def update_wiki_page(wiki, page, content, commit, name = nil, format = nil) def update_wiki_page(wiki, page, content, commit, name = nil, format = nil)
@@ -734,12 +734,3 @@ nav.actions {
display: none; display: none;
} }
} }
/* @section user */
#user p {
text-align: right;
padding-right:0.5em;
font-size: .8em;
line-height: 2.0em;
color: #999;
}
-1
View File
@@ -60,7 +60,6 @@
<body> <body>
<div class="container-lg clearfix"> <div class="container-lg clearfix">
{{{yield}}} {{{yield}}}
{{< user}}
</div> </div>
</body> </body>
</html> </html>
-10
View File
@@ -1,10 +0,0 @@
<div id="user">
<p>
{{#user_authed}}
{{user_name}} | {{user_provider}} | <strong><a href="/__omnigollum__/logout">[Logout]</a></strong>
{{/user_authed}}
{{^user_authed}}
not logged in | <strong><a href="/__omnigollum__/login">[Login]</a></strong>
{{/user_authed}}
<p>
</div>
-13
View File
@@ -87,19 +87,6 @@ module Precious
def latest_changes def latest_changes
false false
end end
# Passthrough additional omniauth parameters for status bar
def user_authed
@user_authed
end
def user_provider
@user.provider
end
def user_name
@user.name
end
end end
end end
+3 -56
View File
@@ -344,45 +344,6 @@ EOF
Precious::App.set(:wiki_options, { :template_page => false }) Precious::App.set(:wiki_options, { :template_page => false })
end end
test "create with template filter without parameter" do
Precious::App.set(:wiki_options, { :template_page => true })
# arrange
now = Time.parse('2022-04-16')
Gollum::TemplateFilter.add_filter("{{today}}", & -> () { now.strftime("%Y-%m-%d") })
template_content = "# Daily Log, {{today}}"
@wiki.write_page("daily-logs/_Template",
:markdown,
template_content)
# act
get "/gollum/create/daily-logs/test"
# assert
assert last_response.ok?
assert_match("# Daily Log, 2022-04-16", last_response.body)
Precious::App.set(:wiki_options, { :template_page => false })
end
test "create with template filter with parameter" do
Precious::App.set(:wiki_options, { :template_page => true })
# arrange
Gollum::TemplateFilter.add_filter("{{page_name}}", & -> (page) { page.name })
template_content = "# Daily Log, {{page_name}}"
@wiki.write_page("daily-logs/_Template",
:markdown,
template_content)
# act
get "/gollum/create/daily-logs/2022-04-16"
# assert
assert last_response.ok?
assert_match("# Daily Log, 2022-04-16", last_response.body)
Precious::App.set(:wiki_options, { :template_page => false })
end
test "edit returns nil for non-existant page" do test "edit returns nil for non-existant page" do
# post '/edit' fails. post '/edit/' works. # post '/edit' fails. post '/edit/' works.
page = 'not-real-page' page = 'not-real-page'
@@ -477,9 +438,9 @@ EOF
assert_equal 'abc', file.raw_data assert_equal 'abc', file.raw_data
Precious::App.set(:wiki_options, {allow_uploads: false}) Precious::App.set(:wiki_options, {allow_uploads: false})
end end
test "upload a file with mode page" do test "upload a file with mode page" do
temp_upload_file = Tempfile.new(['upload', '.file']) << "abc\r" temp_upload_file = Tempfile.new(['upload', '.file']) << 'abc'
temp_upload_file.close temp_upload_file.close
Precious::App.set(:wiki_options, {allow_uploads: true, per_page_uploads: true}) Precious::App.set(:wiki_options, {allow_uploads: true, per_page_uploads: true})
post "/gollum/upload_file", {:file => Rack::Test::UploadedFile.new(::File.open(temp_upload_file))}, {'HTTP_REFERER' => 'http://localhost:4567/Home.md', 'HTTP_HOST' => 'localhost:4567'} post "/gollum/upload_file", {:file => Rack::Test::UploadedFile.new(::File.open(temp_upload_file))}, {'HTTP_REFERER' => 'http://localhost:4567/Home.md', 'HTTP_HOST' => 'localhost:4567'}
@@ -488,21 +449,7 @@ EOF
@wiki.clear_cache @wiki.clear_cache
# Find the file in a page-specific subdir (here: Home), based on referer # Find the file in a page-specific subdir (here: Home), based on referer
file = @wiki.file("uploads/Home/#{::File.basename(temp_upload_file.path)}") file = @wiki.file("uploads/Home/#{::File.basename(temp_upload_file.path)}")
assert_equal "abc\r", file.raw_data assert_equal 'abc', file.raw_data
Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false})
end
test "upload a file with valid extension" do
temp_upload_file = Tempfile.new(['upload', '.txt']) << "abc\r"
temp_upload_file.close
Precious::App.set(:wiki_options, {allow_uploads: true, per_page_uploads: true})
post "/gollum/upload_file", {:file => Rack::Test::UploadedFile.new(::File.open(temp_upload_file))}, {'HTTP_REFERER' => 'http://localhost:4567/Home.md', 'HTTP_HOST' => 'localhost:4567'}
assert_equal 302, last_response.status # redirect is expected
@wiki.clear_cache
# Find the file in a page-specific subdir (here: Home), based on referer
file = @wiki.file("uploads/Home/#{::File.basename(temp_upload_file.path)}")
assert_equal "abc", file.raw_data
Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false}) Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false})
end end
+49 -47
View File
@@ -25,60 +25,62 @@ def load_script(**args)
end end
end end
context '4.x -> 5.x tag migrator' do unless ENV['CI']
include Rack::Test::Methods context '4.x -> 5.x tag migrator' do
include Rack::Test::Methods
setup do setup do
@path = cloned_testpath("examples/lotr_migration.git") @path = cloned_testpath("examples/lotr_migration.git")
end end
test 'repair broken links' do test 'repair broken links' do
# The original contents of Subdir/Foo.md: # The original contents of Subdir/Foo.md:
# #
# waa # waa
# [[Samwi]] # [[Samwi]]
# [[samwise gamgee.mediaWiki]] # [[samwise gamgee.mediaWiki]]
# [[Samwise Gamgee.mediawiki]] # [[Samwise Gamgee.mediawiki]]
# [[Samwise Gamgee]] # [[Samwise Gamgee]]
# [[Test|Samwise Gamgee#Anchor]] # [[Test|Samwise Gamgee#Anchor]]
# [[Waaa|Test]] # [[Waaa|Test]]
# [[Zaa]] # [[Zaa]]
# #
# The contents will be updated after running the migration script. # The contents will be updated after running the migration script.
load_script load_script
file = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r') file = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
assert_equal <<~FILE_CONTENTS, file.read assert_equal <<~FILE_CONTENTS, file.read
waa waa
[[Samwi]] [[Samwi]]
[[/Samwise Gamgee.mediawiki]] [[/Samwise Gamgee.mediawiki]]
[[/Samwise Gamgee.mediawiki]] [[/Samwise Gamgee.mediawiki]]
[[/Samwise Gamgee.md]] [[/Samwise Gamgee.md]]
[[Test|/Samwise Gamgee.md#Anchor]] [[Test|/Samwise Gamgee.md#Anchor]]
[[Waaa|/Bar/Test.md]] [[Waaa|/Bar/Test.md]]
[[Subsub/Zaa.md]] [[Subsub/Zaa.md]]
FILE_CONTENTS FILE_CONTENTS
end end
test 'change spaced filenames to hyphenated filenames' do test 'change spaced filenames to hyphenated filenames' do
load_script(hyphenate: true) load_script(hyphenate: true)
f = ::File.new(::File.join(@path, 'Home.textile'), 'r') f = ::File.new(::File.join(@path, 'Home.textile'), 'r')
output = f.read output = f.read
assert_equal true, output.include?('[[Bilbo-Baggins.md]]') assert_equal true, output.include?('[[Bilbo-Baggins.md]]')
assert_equal true, output.include?('[[evil|Mordor/Eye-Of-Sauron.md]]') assert_equal true, output.include?('[[evil|Mordor/Eye-Of-Sauron.md]]')
end end
test 'migration with page file dir' do test 'migration with page file dir' do
load_script(page_file_dir: 'Subdir') load_script(page_file_dir: 'Subdir')
f = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r') f = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
output = f.read output = f.read
assert_equal true, output.include?('[[Subsub/Zaa.md]]') assert_equal true, output.include?('[[Subsub/Zaa.md]]')
assert_equal true, output.include?('[[Samwi]]') assert_equal true, output.include?('[[Samwi]]')
end end
teardown do teardown do
FileUtils.rm_rf(@path) FileUtils.rm_rf(@path)
end
end end
end end