Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a5e19e3841 | |||
| fdfcbb30e0 | |||
| 9c2f8dfeba | |||
| 8e35688b17 | |||
| 860e8b2ebd | |||
| 0d2ab11604 | |||
| ddc7dba0a2 | |||
| bc3503f374 | |||
| 2dfe103687 | |||
| 95d35d38da | |||
| 81c90e55a7 | |||
| 3f0b61081b | |||
| ecc317886a |
@@ -45,5 +45,6 @@ jobs:
|
||||
tags: ${{ env.DEPLOY_NAME }}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
platforms: linux/amd64, linux/arm64
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
|
||||
@@ -19,7 +19,8 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: Release ${{ github.ref }}
|
||||
draft: false
|
||||
tag_name: ${{ github.ref_name }}
|
||||
release_name: Release ${{ github.ref_name }}
|
||||
draft: true
|
||||
prerelease: false
|
||||
body_path: "LATEST_CHANGES.md"
|
||||
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
ruby: [2.6, 2.7, 3.0]
|
||||
ruby: ['2.6', '2.7', '3.0', '3.1']
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
+2
-1
@@ -32,7 +32,8 @@ COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
|
||||
|
||||
RUN apk add \
|
||||
bash \
|
||||
git
|
||||
git \
|
||||
libc6-compat
|
||||
|
||||
VOLUME /wiki
|
||||
WORKDIR /wiki
|
||||
|
||||
+16
-3
@@ -1,12 +1,25 @@
|
||||
# 5.2.3 2021-04-18
|
||||
# 5.3.0 / 2022-05-25
|
||||
|
||||
* 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
|
||||
|
||||
# 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.
|
||||
|
||||
# 5.2 2021-02-24
|
||||
# 5.2 / 2021-02-24
|
||||
|
||||
* Improved styling and Primer upgrade (@benjaminwil)
|
||||
* Add redirect to rename commit (@ViChyavIn)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# 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
|
||||
@@ -5,21 +5,24 @@ gollum -- A git-based Wiki
|
||||

|
||||
[](https://www.codetriage.com/gollum/gollum)
|
||||
[](https://dometto-cuttingedge.herokuapp.com/github/gollum/gollum/info)
|
||||
[](https://hub.docker.com/r/gollumwiki/gollum)
|
||||
|
||||
|
||||
**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.
|
||||
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.
|
||||
|
||||
## 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](#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 edited with your favourite editor (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 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.
|
||||
* Just clone your GitHub/GitLab wiki and view and edit it locally!
|
||||
|
||||
* Gollum supports advanced functionality like:
|
||||
* [UML diagrams](https://github.com/gollum/gollum/wiki#plantuml-diagrams)
|
||||
* [BibTeX and Citation support](https://github.com/gollum/gollum/wiki/BibTeX-and-Citations)
|
||||
@@ -32,16 +35,17 @@ Gollum is a simple wiki system built on top of Git. A Gollum Wiki is simply a gi
|
||||
|
||||
### SYSTEM REQUIREMENTS
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
## INSTALLATION
|
||||
|
||||
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
|
||||
```
|
||||
### As a Ruby Gem
|
||||
|
||||
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).
|
||||
|
||||
To run, simply:
|
||||
@@ -49,24 +53,30 @@ 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.
|
||||
|
||||
### 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.
|
||||
|
||||
### Markups
|
||||
## 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)
|
||||
* [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)):
|
||||
* [AsciiDoc](http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/) -- `[sudo] gem install asciidoctor`
|
||||
* [Creole](http://www.wikicreole.org/wiki/CheatSheet) -- `[sudo] gem install creole`
|
||||
* [MediaWiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `[sudo] gem install wikicloth`
|
||||
* [Org](http://orgmode.org/worg/dev/org-syntax.html) -- `[sudo] gem install org-ruby`
|
||||
* [AsciiDoc](http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/) -- `gem install asciidoctor`
|
||||
* [Creole](http://www.wikicreole.org/wiki/CheatSheet) -- `gem install creole`
|
||||
* [MediaWiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `gem install wikicloth`
|
||||
* [Org](http://orgmode.org/worg/dev/org-syntax.html) -- `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)
|
||||
* Lower versions should install `Pod::Simple` from CPAN.
|
||||
* [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 your Python 2.
|
||||
* [Textile](http://redcloth.org/hobix.com/textile/quick.html) -- `[sudo] gem install RedCloth`
|
||||
* [ReStructuredText](http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html) -- requires python >= 3
|
||||
* Note that Gollum will also need you to install `docutils` for python
|
||||
* [Textile](http://redcloth.org/hobix.com/textile/quick.html) -- `gem install RedCloth`
|
||||
|
||||
### Markdown flavors
|
||||
|
||||
@@ -90,10 +100,6 @@ 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).
|
||||
|
||||
### 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
|
||||
|
||||
Gollum can also be run as a service. More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-as-a-service).
|
||||
@@ -106,7 +112,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> |
|
||||
| --port | [PORT] | Specify the port to bind Gollum with. Default: `4567`. |
|
||||
| --config | [FILE] | Specify path to Gollum's configuration file. |
|
||||
| --config | [FILE] | Specify path to Gollum's [configuration file](#Config-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`.<sup>2</sup> |
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
require 'rubygems'
|
||||
require 'rake'
|
||||
require 'date'
|
||||
require 'tempfile'
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
@@ -8,6 +9,10 @@ require 'date'
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
def date
|
||||
Time.now.strftime("%Y-%m-%d")
|
||||
end
|
||||
|
||||
def name
|
||||
@name ||= Dir['*.gemspec'].first.split('.').first
|
||||
end
|
||||
@@ -17,6 +22,14 @@ def version
|
||||
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
||||
end
|
||||
|
||||
def latest_changes_file
|
||||
'LATEST_CHANGES.md'
|
||||
end
|
||||
|
||||
def history_file
|
||||
'HISTORY.md'
|
||||
end
|
||||
|
||||
# assumes x.y.z all digit version
|
||||
def next_version
|
||||
# x.y.z
|
||||
@@ -38,14 +51,6 @@ def bump_version
|
||||
new_version
|
||||
end
|
||||
|
||||
def date
|
||||
Date.today.to_s
|
||||
end
|
||||
|
||||
def rubyforge_project
|
||||
name
|
||||
end
|
||||
|
||||
def gemspec_file
|
||||
"#{name}.gemspec"
|
||||
end
|
||||
@@ -114,6 +119,7 @@ task :release => :build do
|
||||
puts "You must be on the master branch to release!"
|
||||
exit!
|
||||
end
|
||||
Rake::Task[:changelog].execute
|
||||
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
||||
sh "git pull --rebase origin master"
|
||||
sh "git tag v#{version}"
|
||||
@@ -143,12 +149,9 @@ task :gemspec => :validate do
|
||||
spec = File.read(gemspec_file)
|
||||
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
||||
|
||||
# replace name version and date
|
||||
# replace name and version
|
||||
replace_header(head, :name)
|
||||
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
|
||||
files = `git ls-files`.
|
||||
@@ -179,6 +182,46 @@ task :validate do
|
||||
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'
|
||||
task :precompile do
|
||||
require './lib/gollum/app.rb'
|
||||
|
||||
+40
-28
@@ -11,8 +11,11 @@ migrate_options = {
|
||||
:hyphenate => true
|
||||
}
|
||||
|
||||
def setting(const)
|
||||
Object.const_defined?(const.upcase) && Object.const_get(const.upcase)
|
||||
def setting(variable_name)
|
||||
class_variable_name = :"@@#{variable_name.to_s}"
|
||||
|
||||
Object.class_variable_defined?(class_variable_name) &&
|
||||
Object.class_variable_get(class_variable_name)
|
||||
end
|
||||
|
||||
opts = OptionParser.new do |opts|
|
||||
@@ -25,7 +28,7 @@ It finds and repairs Gollum link tags that no longer work under 5.x for three re
|
||||
* 5.x wiki internal links are no longer 'global'.
|
||||
|
||||
* NB: you can use the --lenient-tag-lookup option in gollum >= 5.x to enable 4.x-backwards compatible tags.
|
||||
|
||||
|
||||
See https://github.com/gollum/gollum/wiki/5.0-release-notes#filename-handling for more information.
|
||||
Usage of this script comes without any warranty.
|
||||
|
||||
@@ -38,7 +41,7 @@ You can use the --page-file-dir and --config options as you would normally with
|
||||
Requires a non-bare repository. Recommended usage:
|
||||
|
||||
1. Clone your wiki's repository to create a backup.
|
||||
2. Run this script on your cloned repo.
|
||||
2. Run this script on your cloned repo.
|
||||
3. If all looks sane, run the script with the --write option. This will overwrite files in your working directory, but not commit the changes, so you have time to review them.
|
||||
4. Do a 'git diff' to inspect the changes.
|
||||
5. Commit the changes if all looks sane, and push/pull them back into your original repo.
|
||||
@@ -52,23 +55,23 @@ EOF
|
||||
opts.on('--page-file-dir [PATH]', 'Specify the subdirectory for all pages. Default: repository root.') do |path|
|
||||
wiki_options[:page_file_dir] = path
|
||||
end
|
||||
|
||||
|
||||
opts.on('--prefer-relative-links', 'When specified, will try to replace broken links with relative links (\'[[Foo/Bar]]\' instead of \'[[/Subdir/Foo/Bar]]\') where possible.') do
|
||||
migrate_options[:prefer_relative] = true
|
||||
end
|
||||
|
||||
|
||||
opts.on('--hyphenate', 'Default. Repair links that use spaces instead of hyphens: [[Bilbo Baggins]] -> [[Bilbo-Baggins]]') do
|
||||
migrate_options[:hyphenate] = true
|
||||
end
|
||||
|
||||
|
||||
opts.on('--no-hyphenate', 'Turn off the --hyphenate option.') do
|
||||
migrate_options[:hyphenate] = false
|
||||
end
|
||||
|
||||
|
||||
opts.on('--run-silent', 'Don\'t output anything.') do
|
||||
migrate_options[:run_silent] = true
|
||||
end
|
||||
|
||||
|
||||
opts.on('--write', 'No dry run: actually perform the substitutions.') do
|
||||
migrate_options[:no_dry_run] = true
|
||||
end
|
||||
@@ -78,8 +81,11 @@ end
|
||||
begin
|
||||
opts.parse!
|
||||
migrate_options.each do |setting, value|
|
||||
const = setting.to_s.upcase
|
||||
Object.const_set(const, value) unless Object.const_defined?(const)
|
||||
variable_name = :"@@#{setting.to_s}"
|
||||
|
||||
unless Object.class_variable_defined?(variable_name)
|
||||
Object.class_variable_set(variable_name, value)
|
||||
end
|
||||
end
|
||||
wiki_options[:page_file_dir] = setting(:page_file_dir) ? setting(:page_file_dir) : wiki_options[:page_file_dir] # Allow settings :page_file_dir through PAGE_FILE_DIR constant.
|
||||
rescue OptionParser::InvalidOption
|
||||
@@ -88,7 +94,7 @@ rescue OptionParser::InvalidOption
|
||||
exit
|
||||
end
|
||||
|
||||
REPO = ARGV[0] || Dir.pwd
|
||||
wiki_directory = ARGV[0] || Dir.pwd
|
||||
|
||||
require 'gollum-lib'
|
||||
|
||||
@@ -98,7 +104,7 @@ if cfg = options[:config]
|
||||
cfg = File.join(Dir.getwd, cfg) unless cfg.slice(0) == File::SEPARATOR
|
||||
require cfg
|
||||
end
|
||||
|
||||
|
||||
class Gollum::Filter::CodeMigrator < Gollum::Filter::Code
|
||||
def extract(data)
|
||||
case @markup.format
|
||||
@@ -126,7 +132,7 @@ class Gollum::Filter::CodeMigrator < Gollum::Filter::Code
|
||||
next '' if m_end.length < m_start.length
|
||||
lang = m_lang ? m_lang.strip.split.first : nil
|
||||
cache_codeblock($~.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
data.gsub!(/^([ ]{0,3})``` ?([^\r\n]+)?\r?\n(.+?)\r?\n[ ]{0,3}```[ \t]*\r?$/m) do
|
||||
@@ -134,7 +140,7 @@ class Gollum::Filter::CodeMigrator < Gollum::Filter::Code
|
||||
end
|
||||
data
|
||||
end
|
||||
|
||||
|
||||
def process(data)
|
||||
return data if data.nil? || data.size.zero? || @map.size.zero?
|
||||
@map.each do |id, block| ## Just put the code blocks back in verbatim
|
||||
@@ -142,23 +148,23 @@ class Gollum::Filter::CodeMigrator < Gollum::Filter::Code
|
||||
end
|
||||
data
|
||||
end
|
||||
|
||||
|
||||
def cache_codeblock(block)
|
||||
id = "#{open_pattern}#{Digest::SHA1.hexdigest(block)}#{close_pattern}"
|
||||
@map[id] = block
|
||||
id
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
class ::Gollum::Filter::TagMigrator < Gollum::Filter::Tags
|
||||
def process_tag(tag)
|
||||
link_part, extra = parse_tag_parts(tag)
|
||||
orig_tag = %{[[#{tag}]]}
|
||||
return orig_tag if link_part.nil?
|
||||
|
||||
|
||||
img_args = extra ? [extra, link_part] : [link_part]
|
||||
mime = MIME::Types.type_for(::File.extname(img_args.first.to_s)).first
|
||||
|
||||
|
||||
# For any kind of tag other than an internal link: just return the tag.
|
||||
if tag =~ /^_TOC_/ || link_part =~ /^_$/ || link_part =~ /^#{INCLUDE_TAG}/ || (mime && mime.content_type =~ /^image/) || process_external_link_tag(link_part, extra) || process_file_link_tag(link_part, extra)
|
||||
return orig_tag
|
||||
@@ -168,7 +174,7 @@ class ::Gollum::Filter::TagMigrator < Gollum::Filter::Tags
|
||||
link = link_part
|
||||
page = find_page_or_file_from_path(link)
|
||||
anchor = nil
|
||||
|
||||
|
||||
if page.nil? # No match yet, now try finding the page with anchor removed
|
||||
if pos = link.rindex('#')
|
||||
anchor = link[pos..-1]
|
||||
@@ -203,12 +209,12 @@ class ::Gollum::Filter::TagMigrator < Gollum::Filter::Tags
|
||||
pick = possibles.first
|
||||
return tag_for_pick(pick, orig_tag, extra, anchor, @markup.page.path)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
||||
def tag_for_pick(pick, orig_tag, extra, anchor, linking_page_path)
|
||||
pick = if setting(:prefer_relative)
|
||||
overlapping_path = Pathname.new(linking_page_path).dirname.to_s
|
||||
@@ -220,7 +226,7 @@ class ::Gollum::Filter::TagMigrator < Gollum::Filter::Tags
|
||||
end
|
||||
new_tag = extra.nil? ? %{[[#{pick}#{anchor}]]} : %{[[#{extra}|#{pick}#{anchor}]]}
|
||||
log(:info, "#{@markup.page.path}: Changing #{orig_tag} -> #{new_tag}")
|
||||
new_tag
|
||||
new_tag
|
||||
end
|
||||
end
|
||||
|
||||
@@ -232,8 +238,12 @@ end
|
||||
|
||||
filter_chain = [:PlainTextMigrator, :CodeMigrator, :TagMigrator]
|
||||
|
||||
wiki = ::Gollum::Wiki.new(REPO, wiki_options.merge({:filter_chain => filter_chain}))
|
||||
TREE = wiki.tree_list(wiki.ref, true, true).map {|file| ::File.join('/', file.path)}
|
||||
wiki = ::Gollum::Wiki.new(wiki_directory, wiki_options.merge({:filter_chain => filter_chain}))
|
||||
|
||||
Object.class_variable_set(
|
||||
:"@@wiki_tree",
|
||||
wiki.tree_list(wiki.ref, true, true).map {|file| ::File.join('/', file.path)}
|
||||
)
|
||||
|
||||
def find_linked(link)
|
||||
link.gsub!(' ', '-') if setting(:hyphenate) # Match paths containing dashes instead of spaces
|
||||
@@ -243,7 +253,9 @@ def find_linked(link)
|
||||
test_path = ::File.extname(link).empty? ? /#{link}\..+/ : link
|
||||
# Select pages from the wiki whose path =~ 'Foo/Bar/Samwi.*'
|
||||
# Match case-insenstively to mimic 4.x behavior!
|
||||
TREE.select {|path| path =~ /^\/(.*\/)?#{test_path}/i}
|
||||
Object.class_variable_get(:"@@wiki_tree").select { |path|
|
||||
path =~ /^\/(.*\/)?#{test_path}/i
|
||||
}
|
||||
end
|
||||
|
||||
def log(kind, msg = nil)
|
||||
@@ -268,4 +280,4 @@ wiki.pages.each do |page|
|
||||
f.close
|
||||
end
|
||||
log(:none, '====')
|
||||
end
|
||||
end
|
||||
|
||||
+16
-11
@@ -1,12 +1,9 @@
|
||||
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.rubygems_version = '1.3.5'
|
||||
s.required_ruby_version = '>= 2.6'
|
||||
|
||||
s.name = 'gollum'
|
||||
s.version = '5.2.3'
|
||||
s.date = '2021-04-18'
|
||||
s.version = '5.3.0'
|
||||
s.license = 'MIT'
|
||||
|
||||
s.summary = 'A simple, Git-powered wiki.'
|
||||
@@ -23,6 +20,7 @@ Gem::Specification.new do |s|
|
||||
s.rdoc_options = ['--charset=UTF-8']
|
||||
s.extra_rdoc_files = %w[README.md LICENSE]
|
||||
|
||||
s.add_dependency 'rdoc', '~> 6'
|
||||
s.add_dependency 'gollum-lib', '~> 5.1'
|
||||
s.add_dependency 'kramdown', '~> 2.3'
|
||||
s.add_dependency 'kramdown-parser-gfm', '~> 1.1.0'
|
||||
@@ -50,8 +48,10 @@ Gem::Specification.new do |s|
|
||||
# = MANIFEST =
|
||||
s.files = %w[
|
||||
CONTRIBUTING.md
|
||||
Dockerfile
|
||||
Gemfile
|
||||
HISTORY.md
|
||||
LATEST_CHANGES.md
|
||||
LICENSE
|
||||
README.md
|
||||
Rakefile
|
||||
@@ -64,20 +64,21 @@ Gem::Specification.new do |s|
|
||||
contrib/openrc/init.d/gollum
|
||||
contrib/systemd/gollum@.service
|
||||
contrib/sysv-debian/init.d/gollum
|
||||
docker-run.sh
|
||||
gollum.gemspec
|
||||
lib/gollum.rb
|
||||
lib/gollum/app.rb
|
||||
lib/gollum/assets.rb
|
||||
lib/gollum/helpers.rb
|
||||
lib/gollum/public/assets/.sprockets-manifest-de7bb79aec424e55af1acdcc4237b301.json
|
||||
lib/gollum/public/assets/app-0fd228e26bfbe6fe31a2da268eb0e98e780c1191c1a918adf383377946e9c838.js
|
||||
lib/gollum/public/assets/app-0fd228e26bfbe6fe31a2da268eb0e98e780c1191c1a918adf383377946e9c838.js.gz
|
||||
lib/gollum/public/assets/app-ad43ca64b295d8444b10f22ee868f18429268af498f1bc515434878b690e37a2.css
|
||||
lib/gollum/public/assets/app-ad43ca64b295d8444b10f22ee868f18429268af498f1bc515434878b690e37a2.css.gz
|
||||
lib/gollum/public/assets/.sprockets-manifest-160337b312f8e438181baac4aaa37319.json
|
||||
lib/gollum/public/assets/app-309be032396e783b13a47df58f389b7c8e11c2b2d42640560b874f677c25f6e5.css
|
||||
lib/gollum/public/assets/app-309be032396e783b13a47df58f389b7c8e11c2b2d42640560b874f677c25f6e5.css.gz
|
||||
lib/gollum/public/assets/app-f05401ee374f0c7f48fc2bc08e30b4f4db705861fd5895ed70998683b383bfb5.js
|
||||
lib/gollum/public/assets/app-f05401ee374f0c7f48fc2bc08e30b4f4db705861fd5895ed70998683b383bfb5.js.gz
|
||||
lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css
|
||||
lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css.gz
|
||||
lib/gollum/public/assets/editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js
|
||||
lib/gollum/public/assets/editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js.gz
|
||||
lib/gollum/public/assets/editor-9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a.js
|
||||
lib/gollum/public/assets/editor-9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a.js.gz
|
||||
lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css
|
||||
lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css.gz
|
||||
lib/gollum/public/gollum/javascript/HOWTO_UPDATE_ACE.md
|
||||
@@ -1211,6 +1212,7 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/templates/pagination.mustache
|
||||
lib/gollum/templates/search.mustache
|
||||
lib/gollum/templates/searchbar.mustache
|
||||
lib/gollum/templates/user.mustache
|
||||
lib/gollum/templates/wiki_content.mustache
|
||||
lib/gollum/uri_encode_component.rb
|
||||
lib/gollum/views/commit.rb
|
||||
@@ -1219,9 +1221,11 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/views/edit.rb
|
||||
lib/gollum/views/editable.rb
|
||||
lib/gollum/views/error.rb
|
||||
lib/gollum/views/has_math.rb
|
||||
lib/gollum/views/has_page.rb
|
||||
lib/gollum/views/has_user_icons.rb
|
||||
lib/gollum/views/helpers.rb
|
||||
lib/gollum/views/helpers/locale_helpers.rb
|
||||
lib/gollum/views/history.rb
|
||||
lib/gollum/views/latest_changes.rb
|
||||
lib/gollum/views/layout.rb
|
||||
@@ -1230,6 +1234,7 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/views/pagination.rb
|
||||
lib/gollum/views/rss.rb
|
||||
lib/gollum/views/search.rb
|
||||
lib/gollum/views/template_cascade.rb
|
||||
licenses/licenses.txt
|
||||
]
|
||||
# = MANIFEST =
|
||||
|
||||
+4
-3
@@ -13,7 +13,7 @@ require 'rhino' if RUBY_PLATFORM == 'java'
|
||||
require ::File.expand_path('../gollum/uri_encode_component', __FILE__)
|
||||
|
||||
module Gollum
|
||||
VERSION = '5.2.3'
|
||||
VERSION = '5.3.0'
|
||||
|
||||
::I18n.available_locales = [:en]
|
||||
::I18n.load_path = Dir[::File.expand_path("lib/gollum/locales") + "/*.yml"]
|
||||
@@ -29,9 +29,10 @@ module Gollum
|
||||
@@filters[pattern] = replacement
|
||||
end
|
||||
|
||||
def self.apply_filters(data)
|
||||
def self.apply_filters(wiki_page, data)
|
||||
@@filters.each do |pattern, replacement|
|
||||
data.gsub!(pattern, replacement.call)
|
||||
params = replacement.parameters.length == 0 ? nil : wiki_page
|
||||
data.gsub!(pattern, replacement.call(*params))
|
||||
end
|
||||
data
|
||||
end
|
||||
|
||||
+47
-25
@@ -103,8 +103,7 @@ module Precious
|
||||
end
|
||||
|
||||
before do
|
||||
settings.wiki_options[:allow_editing] = settings.wiki_options.fetch(:allow_editing, true)
|
||||
@allow_editing = settings.wiki_options[:allow_editing]
|
||||
@allow_editing = settings.wiki_options.fetch(:allow_editing, true)
|
||||
@critic_markup = settings.wiki_options[:critic_markup]
|
||||
@redirects_enabled = settings.wiki_options.fetch(:redirects_enabled, true)
|
||||
@per_page_uploads = settings.wiki_options[:per_page_uploads]
|
||||
@@ -112,8 +111,6 @@ module Precious
|
||||
|
||||
@wiki_title = settings.wiki_options.fetch(:title, 'Gollum Wiki')
|
||||
|
||||
forbid unless @allow_editing || request.request_method == 'GET'
|
||||
|
||||
if settings.wiki_options[:template_dir]
|
||||
Precious::Views::Layout.extend Precious::Views::TemplateCascade
|
||||
Precious::Views::Layout.template_priority_path = settings.wiki_options[:template_dir]
|
||||
@@ -143,6 +140,8 @@ module Precious
|
||||
config.manifest = Sprockets::Manifest.new(settings.sprockets, @static_assets_path)
|
||||
end
|
||||
end
|
||||
|
||||
forbid unless @allow_editing || request.request_method == 'GET'
|
||||
end
|
||||
|
||||
get '/' do
|
||||
@@ -212,7 +211,7 @@ module Precious
|
||||
end
|
||||
|
||||
get '/edit/*' do
|
||||
forbid unless @allow_editing
|
||||
forbid unless @allow_editing && @user_authed
|
||||
wikip = wiki_page(params[:splat].first)
|
||||
@name = wikip.fullname
|
||||
@path = wikip.path
|
||||
@@ -235,6 +234,7 @@ module Precious
|
||||
|
||||
wiki = wiki_new
|
||||
halt 405 unless wiki.allow_uploads
|
||||
forbid unless @user_authed
|
||||
|
||||
if params[:file]
|
||||
fullname = params[:file][:filename]
|
||||
@@ -274,7 +274,7 @@ module Precious
|
||||
options.merge! author
|
||||
end
|
||||
|
||||
normalize = Gollum::Page.valid_extension?(fullname)
|
||||
options[:normalize] = Gollum::Page.valid_extension?(fullname)
|
||||
|
||||
begin
|
||||
wiki.write_file(reponame, contents, options)
|
||||
@@ -291,6 +291,7 @@ module Precious
|
||||
post '/rename/*' do
|
||||
wikip = wiki_page(params[:splat].first)
|
||||
halt 500 if wikip.nil?
|
||||
forbid unless @user_authed
|
||||
wiki = wikip.wiki
|
||||
page = wikip.page
|
||||
rename = params[:rename]
|
||||
@@ -334,6 +335,7 @@ module Precious
|
||||
path = "/#{clean_url(sanitize_empty_params(params[:path]))}"
|
||||
wiki = wiki_new
|
||||
page = wiki.page(::File.join(path, params[:page]))
|
||||
forbid unless @user_authed
|
||||
|
||||
return if page.nil?
|
||||
if etag != page.sha
|
||||
@@ -354,6 +356,7 @@ module Precious
|
||||
|
||||
post '/delete/*' do
|
||||
forbid unless @allow_editing
|
||||
forbid unless @user_authed
|
||||
wiki = wiki_new
|
||||
filepath = params[:splat].first
|
||||
unless filepath.nil?
|
||||
@@ -365,11 +368,12 @@ module Precious
|
||||
|
||||
get '/create/*' do
|
||||
forbid unless @allow_editing
|
||||
forbid unless @user_authed
|
||||
wikip = wiki_page(params[:splat].first)
|
||||
@name = wikip.name
|
||||
@ext = wikip.ext
|
||||
@path = wikip.path
|
||||
@template_page = load_template(@path) if settings.wiki_options[:template_page]
|
||||
@template_page = load_template(wikip, @path) if settings.wiki_options[:template_page]
|
||||
@allow_uploads = wikip.wiki.allow_uploads
|
||||
@upload_dest = find_upload_dest(wikip.fullpath)
|
||||
|
||||
@@ -390,6 +394,7 @@ module Precious
|
||||
path = sanitize_empty_params(params[:path]) || ''
|
||||
format = params[:format].intern
|
||||
wiki = wiki_new
|
||||
forbid unless @user_authed
|
||||
|
||||
path.gsub!(/^\//, '')
|
||||
|
||||
@@ -555,6 +560,7 @@ module Precious
|
||||
wiki = wiki_new
|
||||
@results = wiki.tree_list
|
||||
|
||||
|
||||
if path
|
||||
@path = Pathname.new(path).cleanpath.to_s
|
||||
check_path = wiki.page_file_dir ? ::File.join(wiki.page_file_dir, @path, '/') : "#{@path}/"
|
||||
@@ -619,28 +625,44 @@ module Precious
|
||||
end
|
||||
end
|
||||
|
||||
def show_page_or_file(fullpath)
|
||||
wiki = wiki_new
|
||||
if page = wiki.page(fullpath)
|
||||
@page = page
|
||||
@name = page.filename_stripped
|
||||
@content = page.formatted_data
|
||||
@upload_dest = find_upload_dest(Pathname.new(fullpath).cleanpath.to_s)
|
||||
def folder_exists(path, wiki)
|
||||
paths = wiki.tree_list
|
||||
return paths.any? { |item| item.path.start_with?(path) }
|
||||
end
|
||||
|
||||
# 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
|
||||
def show_page(page, fullpath, wiki)
|
||||
@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
|
||||
return mustache :page
|
||||
end
|
||||
|
||||
def show_page_or_file(fullpath)
|
||||
wiki = wiki_new
|
||||
|
||||
if fullpath[-1] != '/' ? page = wiki.page(fullpath) : false
|
||||
show_page(page, fullpath, wiki)
|
||||
elsif page = wiki.page("#{fullpath}/#{wiki.index_page}")
|
||||
show_page(page, fullpath, wiki)
|
||||
elsif page = wiki.page("#{fullpath}/#{File.basename(fullpath)}")
|
||||
show_page(page, fullpath, wiki)
|
||||
elsif file = wiki.file(fullpath, wiki.ref, true)
|
||||
show_file(file)
|
||||
elsif @redirects_enabled && redirect_path = wiki.redirects[fullpath]
|
||||
redirect to("#{encodeURIComponent(redirect_path)}?redirected_from=#{encodeURIComponent(fullpath)}")
|
||||
elsif folder_exists(fullpath, wiki)
|
||||
redirect to("/gollum/overview/#{clean_url(encodeURIComponent(fullpath))}")
|
||||
else
|
||||
if @allow_editing
|
||||
if @allow_editing && @user_authed
|
||||
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))}")
|
||||
else
|
||||
@@ -661,9 +683,9 @@ module Precious
|
||||
end
|
||||
end
|
||||
|
||||
def load_template(path)
|
||||
def load_template(wiki_page, path)
|
||||
template_page = wiki_page(::File.join(path, '_Template')).page || wiki_page('/_Template').page
|
||||
template_page ? Gollum::TemplateFilter.apply_filters(template_page.text_data) : nil
|
||||
template_page ? Gollum::TemplateFilter.apply_filters(wiki_page, template_page.text_data) : nil
|
||||
end
|
||||
|
||||
def update_wiki_page(wiki, page, content, commit, name = nil, format = nil)
|
||||
|
||||
@@ -734,3 +734,12 @@ nav.actions {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* @section user */
|
||||
#user p {
|
||||
text-align: right;
|
||||
padding-right:0.5em;
|
||||
font-size: .8em;
|
||||
line-height: 2.0em;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
<body>
|
||||
<div class="container-lg clearfix">
|
||||
{{{yield}}}
|
||||
{{< user}}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<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>
|
||||
@@ -42,7 +42,7 @@ module Precious
|
||||
end
|
||||
|
||||
def fill_argument_content(i18n_key, i18n_value)
|
||||
i18n_value.gsub!(YAML_VARIABLE_REGEXP) do |argument|
|
||||
i18n_value = i18n_value.gsub(YAML_VARIABLE_REGEXP) do |argument|
|
||||
method_name = argument.gsub(/[^\w]/, '')
|
||||
|
||||
next if method_name.nil?
|
||||
|
||||
@@ -87,6 +87,19 @@ module Precious
|
||||
def latest_changes
|
||||
false
|
||||
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
|
||||
|
||||
@@ -11,9 +11,13 @@ module Precious
|
||||
end
|
||||
|
||||
def first_path_available(name)
|
||||
priority = File.join(template_priority_path, "#{name}.#{template_extension}")
|
||||
default = File.join(template_path, "#{name}.#{template_extension}")
|
||||
File.exists?(priority) ? priority : default
|
||||
priority =
|
||||
if template_priority_path
|
||||
File.join(template_priority_path, "#{name}.#{template_extension}")
|
||||
end
|
||||
|
||||
priority && File.exist?(priority) ? priority : default
|
||||
end
|
||||
|
||||
# Method should track lib/mustache/settings.rb from Mustache project.
|
||||
|
||||
+33
-13
@@ -1,18 +1,20 @@
|
||||
require 'rubygems'
|
||||
require 'rack/test'
|
||||
require 'test/unit'
|
||||
require 'shoulda'
|
||||
require 'mocha/setup'
|
||||
require 'fileutils'
|
||||
require 'minitest/autorun'
|
||||
require 'minitest/reporters'
|
||||
require 'minitest/spec'
|
||||
require 'mocha/setup'
|
||||
require 'fileutils'
|
||||
require 'tmpdir'
|
||||
|
||||
# Silence locale validation warning
|
||||
require 'i18n'
|
||||
I18n.enforce_available_locales = false
|
||||
|
||||
MiniTest::Reporters.use!
|
||||
Minitest::Reporters.use! [
|
||||
Minitest::Reporters::DefaultReporter.new({color: true})
|
||||
]
|
||||
|
||||
dir = File.dirname(File.expand_path(__FILE__))
|
||||
$LOAD_PATH.unshift(File.join(dir, '..', 'lib'))
|
||||
@@ -62,14 +64,29 @@ def normal(text)
|
||||
text
|
||||
end
|
||||
|
||||
# test/spec/mini 3
|
||||
# http://gist.github.com/25455
|
||||
# chris@ozmm.org
|
||||
# file:lib/test/spec/mini.rb
|
||||
# The following configuration originates from this gist:
|
||||
|
||||
# http://gist.github.com/25455
|
||||
#
|
||||
# But it has been modified since it was first committed. It allows you to
|
||||
# write tests with an RSpec-like DSL:
|
||||
#
|
||||
# context "my test context" do
|
||||
# setup do
|
||||
# # My test setup
|
||||
# end
|
||||
#
|
||||
# teardown do
|
||||
# # My test teardown
|
||||
# end
|
||||
#
|
||||
# test "some functionality" do
|
||||
# assert true
|
||||
# end
|
||||
# end
|
||||
def context(*args, &block)
|
||||
return super unless (name = args.first) && block
|
||||
require 'test/unit'
|
||||
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
|
||||
klass = Class.new(Minitest::Test) do
|
||||
def self.test(name, &block)
|
||||
define_method("test_#{name.gsub(/\W/, '_')}", &block) if block
|
||||
end
|
||||
@@ -85,10 +102,13 @@ def context(*args, &block)
|
||||
define_method(:teardown, &block)
|
||||
end
|
||||
end
|
||||
|
||||
(
|
||||
class << klass;
|
||||
self
|
||||
end).send(:define_method, :name) { name.gsub(/\W/, '_') }
|
||||
class << klass;
|
||||
self
|
||||
end
|
||||
).send(:define_method, :name) { name.gsub(/\W/, '_') }
|
||||
|
||||
$contexts << klass
|
||||
klass.class_eval &block
|
||||
end
|
||||
|
||||
+54
-34
@@ -3,87 +3,107 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
||||
|
||||
context "Precious::Views::Editing" do
|
||||
include Rack::Test::Methods
|
||||
|
||||
setup do
|
||||
@path = cloned_testpath('examples/revert.git')
|
||||
@path = cloned_testpath('examples/revert.git')
|
||||
Precious::App.set(:gollum_path, @path)
|
||||
Precious::App.set(:wiki_options, {allow_editing: true, allow_uploads: true})
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
end
|
||||
|
||||
teardown do
|
||||
Precious::App.set(:wiki_options, {allow_editing: true, allow_uploads: true})
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
|
||||
test "creating page is blocked" do
|
||||
Precious::App.set(:wiki_options, { allow_editing: false})
|
||||
post "/gollum/create", :content => 'abc', :page => "D",
|
||||
:format => 'markdown', :message => 'def'
|
||||
assert !last_response.ok?
|
||||
test 'creating pages is not blocked' do
|
||||
post '/gollum/create',
|
||||
content: 'abc',
|
||||
format: 'markdown',
|
||||
message: 'def',
|
||||
page: 'D'
|
||||
|
||||
page = @wiki.page('D')
|
||||
assert page.nil?
|
||||
assert_equal last_response.status, 302
|
||||
|
||||
refute_nil @wiki.page('D')
|
||||
end
|
||||
|
||||
test 'creating pages is blocked' do
|
||||
Precious::App.set(:wiki_options, {allow_editing: false, allow_uploads: false})
|
||||
|
||||
post '/gollum/create',
|
||||
content: 'abc',
|
||||
format: 'markdown',
|
||||
message: 'def',
|
||||
page: 'D'
|
||||
|
||||
assert last_response.body.include? 'Forbidden. This wiki is set to no-edit mode.'
|
||||
|
||||
refute last_response.ok?
|
||||
|
||||
assert_nil @wiki.page('D')
|
||||
end
|
||||
|
||||
test ".redirects.gollum file should not be accessible" do
|
||||
Precious::App.set(:wiki_options, { allow_editing: true, allow_uploads: true })
|
||||
get '/.redirects.gollum'
|
||||
assert_match /Accessing this resource is not allowed/, last_response.body
|
||||
end
|
||||
|
||||
|
||||
test ".redirects.gollum file should not be editable" do
|
||||
Precious::App.set(:wiki_options, { allow_editing: true, allow_uploads: true })
|
||||
get '/gollum/edit/.redirects.gollum'
|
||||
assert_match /Changing this resource is not allowed/, last_response.body
|
||||
end
|
||||
|
||||
test "frontend links for editing are not blocked" do
|
||||
Precious::App.set(:wiki_options, { allow_editing: true, allow_uploads: true })
|
||||
get '/A'
|
||||
|
||||
assert_match /Delete this Page/, last_response.body, "'Delete this Page' link is blocked in page template"
|
||||
assert_match /New/, last_response.body, "'New' button is blocked in page template"
|
||||
assert_match /Upload\b/, last_response.body, "'Upload' link is blocked in page template"
|
||||
assert_match /Rename/, last_response.body, "'Rename' link is blocked in page template"
|
||||
assert_match /Edit/, last_response.body, "'Edit' link is blocked in page template"
|
||||
assert last_response.body.include? "Delete this Page"
|
||||
assert last_response.body.include? "New"
|
||||
assert last_response.body.include? "<span>Upload</span>"
|
||||
assert last_response.body.include? "Rename"
|
||||
assert last_response.body.include? "Edit"
|
||||
|
||||
get '/gollum/overview'
|
||||
|
||||
assert_match /New/, last_response.body, "'New' link is blocked in pages template"
|
||||
assert last_response.body.include? "New"
|
||||
|
||||
get '/gollum/history/A'
|
||||
|
||||
assert_no_match /Edit/, last_response.body, "'Edit' link is not blocked in history template"
|
||||
refute last_response.body.include? "Edit"
|
||||
|
||||
get '/gollum/compare/A/fc66539528eb96f21b2bbdbf557788fe8a1196ac..b26b791cb7917c4f37dd9cb4d1e0efb24ac4d26f'
|
||||
get '/gollum/compare/A/fc665395..b26b791c'
|
||||
|
||||
assert_no_match /Edit Page/, last_response.body, "'Edit Page' link is not blocked in compare template"
|
||||
assert_match /Revert Changes/, last_response.body, "'Revert Changes' link is blocked in compare template"
|
||||
refute last_response.body.include? "Edit Page"
|
||||
|
||||
assert last_response.body.include? "Revert Changes"
|
||||
end
|
||||
|
||||
test "frontend links for editing blocked" do
|
||||
Precious::App.set(:wiki_options, { allow_editing: false })
|
||||
Precious::App.set(:wiki_options, {allow_editing: false, allow_uploads: false})
|
||||
|
||||
get '/A'
|
||||
|
||||
assert_no_match /Delete this Page/, last_response.body, "'Delete this Page' link not blocked in page template"
|
||||
assert_no_match /New/, last_response.body, "'New' button not blocked in page template"
|
||||
assert_no_match /Upload\b/, last_response.body, "'Upload' link not blocked in page template"
|
||||
assert_no_match /Rename/, last_response.body, "'Rename' link not blocked in page template"
|
||||
assert_no_match /Edit/, last_response.body, "'Edit' link not blocked in page template"
|
||||
refute last_response.body.include? "Delete this Page"
|
||||
refute last_response.body.include? "<span>Upload</span>"
|
||||
refute last_response.body.include? "Rename"
|
||||
refute last_response.body.include? "Edit"
|
||||
refute last_response.body.include? "New"
|
||||
|
||||
get '/gollum/overview'
|
||||
|
||||
assert_no_match /New/, last_response.body, "'New' link not blocked in pages template"
|
||||
refute last_response.body.include? "New"
|
||||
|
||||
get '/gollum/history/A'
|
||||
|
||||
assert_no_match /Edit/, last_response.body, "'Edit' link not blocked in history template"
|
||||
refute last_response.body.include? "Edit"
|
||||
|
||||
get '/gollum/compare/A/fc66539528eb96f21b2bbdbf557788fe8a1196ac..b26b791cb7917c4f37dd9cb4d1e0efb24ac4d26f'
|
||||
get '/gollum/compare/A/fc665395..b26b791c'
|
||||
|
||||
assert_no_match /Edit Page/, last_response.body, "'Edit Page' link not blocked in compare template"
|
||||
assert_no_match /Revert Changes/, last_response.body, "'Revert Changes' link not blocked in compare template"
|
||||
refute last_response.body.include? "Edit Page"
|
||||
refute last_response.body.include? "Revert Changes"
|
||||
end
|
||||
|
||||
def app
|
||||
Precious::App
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+113
-52
@@ -14,7 +14,7 @@ context "Frontend" do
|
||||
teardown do
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
|
||||
|
||||
test "utf-8 kcode" do
|
||||
assert_equal 'μ†ℱ'.scan(/./), ["μ", "†", "ℱ"]
|
||||
end
|
||||
@@ -104,21 +104,21 @@ EOF
|
||||
page_2 = @wiki.page(page_1.name)
|
||||
assert_equal 'abc', page_2.raw_data
|
||||
assert_equal 'def', page_2.version.message
|
||||
assert_not_equal page_1.version.sha, page_2.version.sha
|
||||
refute_equal page_1.version.sha, page_2.version.sha
|
||||
end
|
||||
|
||||
|
||||
test "edit page fails when page is outdated (edit collision)" do
|
||||
page = @wiki.page('A')
|
||||
old_sha = page.sha
|
||||
post "/gollum/edit/A", :content => 'abc', :page => 'A',
|
||||
:format => page.format, :message => 'def', :etag => old_sha
|
||||
assert last_response.ok?
|
||||
|
||||
|
||||
@wiki.clear_cache
|
||||
page = @wiki.page('A')
|
||||
new_sha = page.sha
|
||||
assert_not_equal old_sha, new_sha
|
||||
|
||||
refute_equal old_sha, new_sha
|
||||
|
||||
post "/gollum/edit/A", :content => 'def', :page => 'A',
|
||||
:format => page.format, :message => 'def', :etag => old_sha
|
||||
assert_equal last_response.status, 412
|
||||
@@ -134,7 +134,7 @@ EOF
|
||||
page_2 = @wiki.page(page_1.name)
|
||||
assert_equal 'abc', page_2.raw_data
|
||||
assert_equal '[no message]', page_2.version.message
|
||||
assert_not_equal page_1.version.sha, page_2.version.sha
|
||||
refute_equal page_1.version.sha, page_2.version.sha
|
||||
end
|
||||
|
||||
test "edit page with slash" do
|
||||
@@ -165,12 +165,12 @@ EOF
|
||||
assert_equal 'header', header_2.raw_data
|
||||
assert_equal 'footer', foot_2.raw_data
|
||||
assert_equal 'def', foot_2.version.message
|
||||
assert_not_equal foot_1.version.sha, foot_2.version.sha
|
||||
assert_not_equal header_1.version.sha, header_2.version.sha
|
||||
refute_equal foot_1.version.sha, foot_2.version.sha
|
||||
refute_equal header_1.version.sha, header_2.version.sha
|
||||
|
||||
assert_equal 'sidebar', side_2.raw_data
|
||||
assert_equal 'def', side_2.version.message
|
||||
assert_not_equal side_1.version.sha, side_2.version.sha
|
||||
refute_equal side_1.version.sha, side_2.version.sha
|
||||
assert_equal commits, @wiki.repo.commits('master').size
|
||||
end
|
||||
|
||||
@@ -187,7 +187,7 @@ EOF
|
||||
page_2 = @wiki.page('C')
|
||||
assert_equal "INITIAL\n\nSPAM2\n", page_2.raw_data
|
||||
assert_equal 'def', page_2.last_version.message
|
||||
assert_not_equal page_1.version.sha, page_2.version.sha
|
||||
refute_equal page_1.version.sha, page_2.version.sha
|
||||
end
|
||||
|
||||
test "rename preserves format" do
|
||||
@@ -222,7 +222,7 @@ EOF
|
||||
|
||||
test "renames page in subdirectory" do
|
||||
page_1 = @wiki.page("G/H")
|
||||
assert_not_equal page_1, nil
|
||||
refute_equal page_1, nil
|
||||
post "/gollum/rename/G/H", :rename => "/I/C", :message => 'def'
|
||||
|
||||
follow_redirect!
|
||||
@@ -234,12 +234,12 @@ EOF
|
||||
page_2 = @wiki.page('I/C')
|
||||
assert_equal "INITIAL\n\nSPAM2\n", page_2.raw_data
|
||||
assert_equal 'def', page_2.last_version.message
|
||||
assert_not_equal page_1.version.sha, page_2.version.sha
|
||||
refute_equal page_1.version.sha, page_2.version.sha
|
||||
end
|
||||
|
||||
test "renames page relative in subdirectory" do
|
||||
page_1 = @wiki.page("G/H")
|
||||
assert_not_equal page_1, nil
|
||||
refute_equal page_1, nil
|
||||
post "/gollum/rename/G/H", :rename => "K/C", :message => 'def'
|
||||
|
||||
follow_redirect!
|
||||
@@ -251,7 +251,7 @@ EOF
|
||||
page_2 = @wiki.page('G/K/C')
|
||||
assert_equal "INITIAL\n\nSPAM2\n", page_2.raw_data
|
||||
assert_equal 'def', page_2.last_version.message
|
||||
assert_not_equal page_1.version.sha, page_2.version.sha
|
||||
refute_equal page_1.version.sha, page_2.version.sha
|
||||
end
|
||||
|
||||
test "creates page" do
|
||||
@@ -320,7 +320,7 @@ EOF
|
||||
name = "#{dir}/bar"
|
||||
get "/gollum/create/#{name}"
|
||||
assert_match(/\/#{dir}/, last_response.body)
|
||||
assert_no_match(/[^\/]#{dir}/, last_response.body)
|
||||
refute_match(/[^\/]#{dir}/, last_response.body)
|
||||
end
|
||||
|
||||
test "create with template succeed if template exists" do
|
||||
@@ -344,6 +344,45 @@ EOF
|
||||
Precious::App.set(:wiki_options, { :template_page => false })
|
||||
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
|
||||
# post '/edit' fails. post '/edit/' works.
|
||||
page = 'not-real-page'
|
||||
@@ -351,7 +390,7 @@ EOF
|
||||
post '/gollum/edit/', :content => 'edit_msg',
|
||||
:page => page, :path => path, :message => ''
|
||||
page_e = @wiki.page(::File.join(path,page))
|
||||
assert_equal nil, page_e
|
||||
assert_nil page_e
|
||||
end
|
||||
|
||||
test "edit allows changing format" do
|
||||
@@ -407,50 +446,72 @@ EOF
|
||||
|
||||
@wiki.clear_cache
|
||||
page = @wiki.page(name)
|
||||
assert_not_equal 'abc', page.raw_data
|
||||
refute_equal 'abc', page.raw_data
|
||||
end
|
||||
|
||||
|
||||
test "uploading is not allowed unless explicitly enabled" do
|
||||
temp_upload_file = Tempfile.new(['upload', '.file']) << 'abc'
|
||||
temp_upload_file.close
|
||||
post "/gollum/upload_file", :file => Rack::Test::UploadedFile.new(::File.open(temp_upload_file))
|
||||
|
||||
Precious::App.set(
|
||||
:wiki_options,
|
||||
{allow_uploads: false, per_page_uploads: false}
|
||||
)
|
||||
|
||||
post '/gollum/upload_file',
|
||||
file: Rack::Test::UploadedFile.new(File.open(temp_upload_file))
|
||||
|
||||
assert_equal 405, last_response.status
|
||||
end
|
||||
|
||||
|
||||
test "upload a file with mode dir" do
|
||||
temp_upload_file = Tempfile.new(['upload', '.file']) << 'abc'
|
||||
temp_upload_file.close
|
||||
Precious::App.set(:wiki_options, {allow_uploads: true})
|
||||
|
||||
|
||||
post "/gollum/upload_file", :file => Rack::Test::UploadedFile.new(::File.open(temp_upload_file))
|
||||
|
||||
|
||||
assert_equal 302, last_response.status # redirect is expected
|
||||
@wiki.clear_cache
|
||||
file = @wiki.file("uploads/#{::File.basename(temp_upload_file.path)}")
|
||||
assert_equal 'abc', file.raw_data
|
||||
Precious::App.set(:wiki_options, {allow_uploads: false})
|
||||
end
|
||||
|
||||
|
||||
test "upload a file with mode page" do
|
||||
temp_upload_file = Tempfile.new(['upload', '.file']) << 'abc'
|
||||
temp_upload_file = Tempfile.new(['upload', '.file']) << "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
|
||||
assert_equal "abc\r", 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})
|
||||
end
|
||||
|
||||
test "upload a file with https referer" do
|
||||
temp_upload_file = Tempfile.new(['https_upload', '.file']) << 'abc'
|
||||
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' => 'https://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
|
||||
@@ -458,8 +519,8 @@ EOF
|
||||
assert_equal 'abc', file.raw_data
|
||||
Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false})
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
test "guard against uploading an existing file" do
|
||||
temp_upload_file = Tempfile.new(['upload', '.file']) << 'abc'
|
||||
temp_upload_file.close
|
||||
@@ -471,7 +532,7 @@ EOF
|
||||
assert_equal 409, last_response.status
|
||||
Precious::App.set(:wiki_options, {allow_uploads: false})
|
||||
end
|
||||
|
||||
|
||||
test "delete a page" do
|
||||
name = "deleteme"
|
||||
post "/gollum/create", :content => 'abc', :page => name,
|
||||
@@ -483,7 +544,7 @@ EOF
|
||||
|
||||
@wiki.clear_cache
|
||||
page = @wiki.page(name)
|
||||
assert_equal nil, page
|
||||
assert_nil page
|
||||
end
|
||||
|
||||
test "previews content" do
|
||||
@@ -507,7 +568,7 @@ EOF
|
||||
|
||||
@wiki.clear_cache
|
||||
page2 = @wiki.page('B')
|
||||
assert_not_equal page1.version.sha, page2.version.sha
|
||||
refute_equal page1.version.sha, page2.version.sha
|
||||
assert_equal "INITIAL", page2.raw_data.strip
|
||||
assert_equal "Revert commit 7c45b5f", page2.version.message
|
||||
end
|
||||
@@ -521,7 +582,7 @@ EOF
|
||||
|
||||
@wiki.clear_cache
|
||||
page2 = @wiki.page('A')
|
||||
assert_not_equal page1.version.sha, page2.version.sha
|
||||
refute_equal page1.version.sha, page2.version.sha
|
||||
assert_equal "INITIAL", page2.raw_data.strip
|
||||
end
|
||||
|
||||
@@ -535,7 +596,7 @@ EOF
|
||||
page2 = @wiki.page('A')
|
||||
assert_equal page1.version.sha, page2.version.sha
|
||||
end
|
||||
|
||||
|
||||
=begin
|
||||
# redirects are now handled by class MapGollum in bin/gollum
|
||||
# they should be set in config.ru
|
||||
@@ -583,7 +644,7 @@ EOF
|
||||
{ :name => 'user1', :email => 'user1' });
|
||||
|
||||
get page
|
||||
assert_no_match /custom.js/, last_response.body
|
||||
refute_match /custom.js/, last_response.body
|
||||
end
|
||||
|
||||
test "add custom.js if setting" do
|
||||
@@ -601,7 +662,7 @@ EOF
|
||||
|
||||
test "don't allow changing custom js or css" do
|
||||
Precious::App.set(:wiki_options, { :js => true, :css => true })
|
||||
|
||||
|
||||
['create', 'edit'].each do |route|
|
||||
['.css', '.js'].each do |ext|
|
||||
get "/gollum/#{route}/custom#{ext}"
|
||||
@@ -634,7 +695,7 @@ EOF
|
||||
:page => 'Multibyte', :format => :markdown, :message => 'mesg'
|
||||
|
||||
page = @wiki.page('Multibyte')
|
||||
|
||||
|
||||
post "/gollum/edit/Multibyte",
|
||||
:content => 'りんご', :header => 'みかん', :footer => 'バナナ', :sidebar => 'スイカ',
|
||||
:page => 'Multibyte', :format => :markdown, :message => 'mesg', :etag => page.sha
|
||||
@@ -652,7 +713,7 @@ EOF
|
||||
get "A"
|
||||
|
||||
assert last_response.ok?
|
||||
assert_no_match /meta name="robots" content="noindex, nofollow"/, last_response.body
|
||||
refute_match /meta name="robots" content="noindex, nofollow"/, last_response.body
|
||||
|
||||
get "A/fc66539528eb96f21b2bbdbf557788fe8a1196ac"
|
||||
|
||||
@@ -831,10 +892,10 @@ context "Frontend with lotr" do
|
||||
test "show revision of specific file" do
|
||||
old_sha = "df26e61e707116f81ebc6b935ec6d1676b7e96c4"
|
||||
update_sha = "f803c64d11407b23797325e3843f3f378b78f611"
|
||||
|
||||
|
||||
get "Data.csv/#{old_sha}"
|
||||
assert last_response.ok?
|
||||
assert_no_match /Samwise,Gamgee/, last_response.body
|
||||
refute_match /Samwise,Gamgee/, last_response.body
|
||||
|
||||
get "Data.csv/#{update_sha}"
|
||||
assert last_response.ok?
|
||||
@@ -879,7 +940,7 @@ context "Frontend with page-file-dir" do
|
||||
name = "#{dir}/baz"
|
||||
get "/gollum/create/#{name}"
|
||||
assert_match(/\/#{dir}/, last_response.body)
|
||||
assert_no_match(/[^\/]#{dir}/, last_response.body)
|
||||
refute_match(/[^\/]#{dir}/, last_response.body)
|
||||
end
|
||||
|
||||
test "use custom.css from page-file-dir path if page-file-dir is set" do
|
||||
@@ -920,7 +981,7 @@ end
|
||||
|
||||
context "Frontend with empty repo" do
|
||||
include Rack::Test::Methods
|
||||
|
||||
|
||||
setup do
|
||||
@path = cloned_testpath("examples/empty.git")
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
@@ -931,11 +992,11 @@ context "Frontend with empty repo" do
|
||||
teardown do
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
|
||||
|
||||
def app
|
||||
Precious::App
|
||||
end
|
||||
|
||||
|
||||
test 'previews content on the first page of an empty wiki' do
|
||||
post '/gollum/preview', :content => 'abc', :format => 'markdown'
|
||||
assert last_response.ok?
|
||||
@@ -947,12 +1008,12 @@ context "Frontend with empty repo" do
|
||||
assert_equal '/gollum/create/Home', last_request.fullpath
|
||||
assert last_response.ok?
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
context 'Frontend with base path' do
|
||||
include Rack::Test::Methods
|
||||
|
||||
|
||||
setup do
|
||||
@path = cloned_testpath("examples/lotr.git")
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
@@ -964,24 +1025,24 @@ context 'Frontend with base path' do
|
||||
teardown do
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
|
||||
|
||||
test 'page with base path' do
|
||||
get '/wiki/Home'
|
||||
assert last_response.ok?
|
||||
end
|
||||
|
||||
|
||||
test 'base path mathjax assets' do
|
||||
get '/wiki/Home'
|
||||
assert last_response.ok?
|
||||
assert last_response.body.include?('<script defer src="/wiki/gollum/assets/mathjax/MathJax.js?config=')
|
||||
end
|
||||
|
||||
|
||||
test 'compare view' do
|
||||
get '/wiki/gollum/compare/Bilbo-Baggins.md?versions[]=f25eccd98e9b667f9e22946f3e2f945378b8a72d&versions[]=5bc1aaec6149e854078f1d0f8b71933bbc6c2e43'
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
assert_equal '/wiki/gollum/compare/Bilbo-Baggins.md/5bc1aaec6149e854078f1d0f8b71933bbc6c2e43...f25eccd98e9b667f9e22946f3e2f945378b8a72d', last_request.fullpath
|
||||
|
||||
|
||||
get '/wiki/gollum/compare/Bilbo-Baggins.md?versions[]=f25eccd98e9b667f9e22946f3e2f945378b8a72d'
|
||||
follow_redirect!
|
||||
assert last_response.ok?
|
||||
@@ -992,7 +1053,7 @@ context 'Frontend with base path' do
|
||||
assert last_response.ok?
|
||||
assert_equal '/wiki/gollum/history/Bilbo-Baggins.md', last_request.fullpath
|
||||
end
|
||||
|
||||
|
||||
def app
|
||||
Precious::MapGollum.new(@base_path)
|
||||
end
|
||||
|
||||
+64
-66
@@ -1,28 +1,6 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
||||
|
||||
# Original contents of Subdir/Foo.md:
|
||||
# waa
|
||||
# [[Samwi]]
|
||||
# [[samwise gamgee.mediaWiki]]
|
||||
# [[Samwise Gamgee.mediawiki]]
|
||||
# [[Samwise Gamgee]]
|
||||
# [[Test|Samwise Gamgee#Anchor]]
|
||||
# [[Waaa|Test]]
|
||||
# [[Zaa]]
|
||||
|
||||
# Contents of Subdir/Foo.md after successful tag migration
|
||||
result = <<EOF
|
||||
waa
|
||||
[[Samwi]]
|
||||
[[/Samwise Gamgee.mediawiki]]
|
||||
[[/Samwise Gamgee.mediawiki]]
|
||||
[[/Samwise Gamgee.md]]
|
||||
[[Test|/Samwise Gamgee.md#Anchor]]
|
||||
[[Waaa|/Bar/Test.md]]
|
||||
[[Subsub/Zaa.md]]
|
||||
EOF
|
||||
|
||||
def load_script(**args)
|
||||
settings = {
|
||||
:run_silent => true,
|
||||
@@ -31,56 +9,76 @@ def load_script(**args)
|
||||
:hyphenate => false,
|
||||
:page_file_dir => nil,
|
||||
}.merge(args)
|
||||
|
||||
settings.each do |const, val|
|
||||
const_name = const.to_s.upcase
|
||||
Object.const_set(const_name, val) unless Object.const_defined?(const_name) && Object.const_get(const_name) == val
|
||||
|
||||
settings.each do |setting, val|
|
||||
variable_name = :"@@#{setting.to_s}"
|
||||
|
||||
unless Object.class_variable_defined?(variable_name) && Object.class_variable_get(variable_name) == val
|
||||
Object.class_variable_set(variable_name, val)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
script_path = File.expand_path(File.join(File.dirname(__FILE__), '../', 'bin', 'gollum-migrate-tags'))
|
||||
|
||||
|
||||
Dir.chdir(@path) do
|
||||
load script_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless ENV['CI']
|
||||
context '4.x -> 5.x tag migrator' do
|
||||
include Rack::Test::Methods
|
||||
|
||||
context '4.x -> 5.x tag migrator' do
|
||||
include Rack::Test::Methods
|
||||
|
||||
setup do
|
||||
@path = cloned_testpath("examples/lotr_migration.git")
|
||||
end
|
||||
|
||||
test 'repair broken links' do
|
||||
load_script
|
||||
|
||||
f = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
|
||||
assert_equal result, f.read
|
||||
end
|
||||
|
||||
test 'change spaced filenames to hyphenated filenames' do
|
||||
load_script(hyphenate: true)
|
||||
|
||||
f = ::File.new(::File.join(@path, 'Home.textile'), 'r')
|
||||
output = f.read
|
||||
assert_equal true, output.include?('[[Bilbo-Baggins.md]]')
|
||||
assert_equal true, output.include?('[[evil|Mordor/Eye-Of-Sauron.md]]')
|
||||
end
|
||||
|
||||
test 'migration with page file dir' do
|
||||
load_script(page_file_dir: 'Subdir')
|
||||
|
||||
f = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
|
||||
output = f.read
|
||||
assert_equal true, output.include?('[[Subsub/Zaa.md]]')
|
||||
assert_equal true, output.include?('[[Samwi]]')
|
||||
end
|
||||
|
||||
teardown do
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
setup do
|
||||
@path = cloned_testpath("examples/lotr_migration.git")
|
||||
end
|
||||
|
||||
end
|
||||
test 'repair broken links' do
|
||||
# The original contents of Subdir/Foo.md:
|
||||
#
|
||||
# waa
|
||||
# [[Samwi]]
|
||||
# [[samwise gamgee.mediaWiki]]
|
||||
# [[Samwise Gamgee.mediawiki]]
|
||||
# [[Samwise Gamgee]]
|
||||
# [[Test|Samwise Gamgee#Anchor]]
|
||||
# [[Waaa|Test]]
|
||||
# [[Zaa]]
|
||||
#
|
||||
# The contents will be updated after running the migration script.
|
||||
load_script
|
||||
|
||||
file = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
|
||||
assert_equal <<~FILE_CONTENTS, file.read
|
||||
waa
|
||||
[[Samwi]]
|
||||
[[/Samwise Gamgee.mediawiki]]
|
||||
[[/Samwise Gamgee.mediawiki]]
|
||||
[[/Samwise Gamgee.md]]
|
||||
[[Test|/Samwise Gamgee.md#Anchor]]
|
||||
[[Waaa|/Bar/Test.md]]
|
||||
[[Subsub/Zaa.md]]
|
||||
FILE_CONTENTS
|
||||
end
|
||||
|
||||
test 'change spaced filenames to hyphenated filenames' do
|
||||
load_script(hyphenate: true)
|
||||
|
||||
f = ::File.new(::File.join(@path, 'Home.textile'), 'r')
|
||||
output = f.read
|
||||
assert_equal true, output.include?('[[Bilbo-Baggins.md]]')
|
||||
assert_equal true, output.include?('[[evil|Mordor/Eye-Of-Sauron.md]]')
|
||||
end
|
||||
|
||||
test 'migration with page file dir' do
|
||||
load_script(page_file_dir: 'Subdir')
|
||||
|
||||
f = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
|
||||
output = f.read
|
||||
assert_equal true, output.include?('[[Subsub/Zaa.md]]')
|
||||
assert_equal true, output.include?('[[Samwi]]')
|
||||
end
|
||||
|
||||
teardown do
|
||||
FileUtils.rm_rf(@path)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ context "Precious::Views::Page" do
|
||||
@view.instance_variable_set :@content, page.formatted_data
|
||||
@view.instance_variable_set :@h1_title, false
|
||||
|
||||
assert_include @view.breadcrumb, "数学 📘"
|
||||
assert_includes @view.breadcrumb, "数学 📘"
|
||||
end
|
||||
|
||||
test 'page <title> is the page header from content, if present' do
|
||||
|
||||
@@ -1,43 +1,59 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
||||
|
||||
class TestTemplateCascade < Minitest::Unit::TestCase
|
||||
context "Precious::Views::TemplateCascade" do
|
||||
include Rack::Test::Methods
|
||||
|
||||
def setup
|
||||
setup do
|
||||
@path = cloned_testpath('examples/lotr.git')
|
||||
Precious::App.set(:gollum_path, @path)
|
||||
Precious::App.set(:wiki_options, {template_dir: testpath('examples/template_cascade')})
|
||||
Precious::App.set(
|
||||
:wiki_options,
|
||||
{template_dir: testpath('examples/template_cascade')}
|
||||
)
|
||||
@wiki = Gollum::Wiki.new(@path)
|
||||
end
|
||||
|
||||
def teardown
|
||||
teardown do
|
||||
FileUtils.rm_rf(@path)
|
||||
|
||||
Precious::App.set(:wiki_options, {template_dir: nil})
|
||||
|
||||
# The following line has been added to avoid order-dependent test failures.
|
||||
# We saw issues where the class variable `@@template_priority_path` was not
|
||||
# being reset between test cases.
|
||||
Precious::Views::TemplateCascade.class_variable_set(
|
||||
:@@template_priority_path,
|
||||
nil
|
||||
)
|
||||
end
|
||||
|
||||
def app
|
||||
Precious::App
|
||||
Precious::App.new
|
||||
end
|
||||
|
||||
def test_overridden_page_template_is_used
|
||||
test "overridden_page_template_is_used" do
|
||||
get '/Home'
|
||||
|
||||
assert last_response.body.include?('PAGE_OVERRIDE')
|
||||
end
|
||||
|
||||
def test_overridden_navbar_partial_is_used
|
||||
test "test_overridden_navbar_partial_is_used" do
|
||||
get '/Home'
|
||||
|
||||
assert last_response.body.include?('NAVBAR_OVERRIDE')
|
||||
end
|
||||
|
||||
def test_overridden_templates_are_ignore_without_template_dir_set
|
||||
test "test_overridden_templates_are_ignore_without_template_dir_set" do
|
||||
Precious::App.set(:wiki_options, {template_dir: nil})
|
||||
|
||||
get '/Home'
|
||||
|
||||
assert_equal '/Home', last_request.fullpath
|
||||
|
||||
assert last_response.ok?
|
||||
assert_no_match /PAGE_OVERRIDE/, last_response.body
|
||||
assert_no_match /NAVBAR_OVERRIDE/, last_response.body
|
||||
|
||||
refute_match /PAGE_OVERRIDE/, last_response.body
|
||||
refute_match /NAVBAR_OVERRIDE/, last_response.body
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user