Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bc490c64e5 | |||
| 33ed562d1c | |||
| 3f4162e2cc | |||
| 489f6d7c0f | |||
| 1548034a06 | |||
| f90e7a81b8 | |||
| b9fef4175c | |||
| dd722e9b06 | |||
| e60d4e397c |
@@ -19,8 +19,7 @@ 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_name }}
|
||||
release_name: Release ${{ github.ref_name }}
|
||||
draft: true
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: Release ${{ github.ref }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
body_path: "LATEST_CHANGES.md"
|
||||
|
||||
+3
-16
@@ -1,25 +1,12 @@
|
||||
# 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
|
||||
# 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)
|
||||
|
||||
@@ -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
|
||||
@@ -5,24 +5,21 @@ 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)
|
||||
|
||||
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
|
||||
|
||||
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 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.
|
||||
* 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 strives to be compatible with GitHub wikis (see `--lenient-tag-lookup`)
|
||||
* 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)
|
||||
@@ -35,17 +32,16 @@ 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 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
|
||||
|
||||
### 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).
|
||||
|
||||
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.
|
||||
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/) -- `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`
|
||||
* [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`
|
||||
* [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 >= 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`
|
||||
* [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`
|
||||
|
||||
### 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).
|
||||
|
||||
### 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).
|
||||
@@ -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> |
|
||||
| --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`. |
|
||||
| --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,7 +1,5 @@
|
||||
require 'rubygems'
|
||||
require 'rake'
|
||||
require 'date'
|
||||
require 'tempfile'
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
@@ -9,10 +7,6 @@ require 'tempfile'
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
def date
|
||||
Time.now.strftime("%Y-%m-%d")
|
||||
end
|
||||
|
||||
def name
|
||||
@name ||= Dir['*.gemspec'].first.split('.').first
|
||||
end
|
||||
@@ -22,14 +16,6 @@ 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
|
||||
@@ -119,7 +105,6 @@ 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}"
|
||||
@@ -182,46 +167,6 @@ 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'
|
||||
|
||||
+8
-15
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
|
||||
s.required_ruby_version = '>= 2.6'
|
||||
|
||||
s.name = 'gollum'
|
||||
s.version = '5.3.0'
|
||||
s.version = '5.2.3'
|
||||
s.license = 'MIT'
|
||||
|
||||
s.summary = 'A simple, Git-powered wiki.'
|
||||
@@ -48,10 +48,8 @@ Gem::Specification.new do |s|
|
||||
# = MANIFEST =
|
||||
s.files = %w[
|
||||
CONTRIBUTING.md
|
||||
Dockerfile
|
||||
Gemfile
|
||||
HISTORY.md
|
||||
LATEST_CHANGES.md
|
||||
LICENSE
|
||||
README.md
|
||||
Rakefile
|
||||
@@ -64,21 +62,20 @@ 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-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/.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/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css
|
||||
lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css.gz
|
||||
lib/gollum/public/assets/editor-9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a.js
|
||||
lib/gollum/public/assets/editor-9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a.js.gz
|
||||
lib/gollum/public/assets/editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js
|
||||
lib/gollum/public/assets/editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.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
|
||||
@@ -1212,7 +1209,6 @@ 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
|
||||
@@ -1221,11 +1217,9 @@ 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
|
||||
@@ -1234,7 +1228,6 @@ 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 =
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ require 'rhino' if RUBY_PLATFORM == 'java'
|
||||
require ::File.expand_path('../gollum/uri_encode_component', __FILE__)
|
||||
|
||||
module Gollum
|
||||
VERSION = '5.3.0'
|
||||
VERSION = '5.2.3'
|
||||
|
||||
::I18n.available_locales = [:en]
|
||||
::I18n.load_path = Dir[::File.expand_path("lib/gollum/locales") + "/*.yml"]
|
||||
|
||||
+4
-49
@@ -211,7 +211,7 @@ module Precious
|
||||
end
|
||||
|
||||
get '/edit/*' do
|
||||
forbid unless @allow_editing && @user_authed
|
||||
forbid unless @allow_editing
|
||||
wikip = wiki_page(params[:splat].first)
|
||||
@name = wikip.fullname
|
||||
@path = wikip.path
|
||||
@@ -234,7 +234,6 @@ module Precious
|
||||
|
||||
wiki = wiki_new
|
||||
halt 405 unless wiki.allow_uploads
|
||||
forbid unless @user_authed
|
||||
|
||||
if params[:file]
|
||||
fullname = params[:file][:filename]
|
||||
@@ -274,7 +273,7 @@ module Precious
|
||||
options.merge! author
|
||||
end
|
||||
|
||||
options[:normalize] = Gollum::Page.valid_extension?(fullname)
|
||||
normalize = Gollum::Page.valid_extension?(fullname)
|
||||
|
||||
begin
|
||||
wiki.write_file(reponame, contents, options)
|
||||
@@ -291,7 +290,6 @@ 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]
|
||||
@@ -335,7 +333,6 @@ 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
|
||||
@@ -356,7 +353,6 @@ module Precious
|
||||
|
||||
post '/delete/*' do
|
||||
forbid unless @allow_editing
|
||||
forbid unless @user_authed
|
||||
wiki = wiki_new
|
||||
filepath = params[:splat].first
|
||||
unless filepath.nil?
|
||||
@@ -368,7 +364,6 @@ 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
|
||||
@@ -394,7 +389,6 @@ module Precious
|
||||
path = sanitize_empty_params(params[:path]) || ''
|
||||
format = params[:format].intern
|
||||
wiki = wiki_new
|
||||
forbid unless @user_authed
|
||||
|
||||
path.gsub!(/^\//, '')
|
||||
|
||||
@@ -626,41 +620,7 @@ module Precious
|
||||
|
||||
def show_page_or_file(fullpath)
|
||||
wiki = wiki_new
|
||||
|
||||
|
||||
# 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)
|
||||
if page = wiki.page(fullpath)
|
||||
@page = page
|
||||
@name = page.filename_stripped
|
||||
@content = page.formatted_data
|
||||
@@ -678,13 +638,8 @@ module Precious
|
||||
show_file(file)
|
||||
elsif @redirects_enabled && redirect_path = wiki.redirects[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
|
||||
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
|
||||
redirect to("/gollum/create/#{clean_url(encodeURIComponent(path))}")
|
||||
else
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
en:
|
||||
pagination:
|
||||
aria:
|
||||
label: Pagination
|
||||
next_page: Next page
|
||||
previous_page: Previous page
|
||||
next: Next
|
||||
previous: Previous
|
||||
precious/views/compare:
|
||||
back_to_page_history: Back to Page History
|
||||
back_to_top: Back to Top
|
||||
comparison_of: Comparison of
|
||||
comparing_versions_of: Comparing versions of
|
||||
comparing_from: "Comparing %{before} to %{after}"
|
||||
revert: Revert Changes
|
||||
precious/views/error:
|
||||
error: Error
|
||||
precious/views/history:
|
||||
browse_in_history_description: Browse the page at this point in the history
|
||||
compare_revisions: Compare Revisions
|
||||
history_for: History for
|
||||
precious/views/latest_changes:
|
||||
title: Latest Changes (Globally)
|
||||
precious/views/layout:
|
||||
title: Home
|
||||
precious/views/overview:
|
||||
back_to_top: Back to Top
|
||||
delete_confirmation: "Are you sure you want to delete %{name}?"
|
||||
no_pages_in: There are no pages in
|
||||
on: "on"
|
||||
title: "Overview of %{ref}"
|
||||
precious/views/search:
|
||||
aria:
|
||||
show_all: "Show all %{count} hits in this page"
|
||||
back_to_top: Back to Top
|
||||
no_results: There are no results for your search
|
||||
search_results_for: Search results for
|
||||
title: "Search results for %{query}"
|
||||
@@ -734,12 +734,3 @@ nav.actions {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* @section user */
|
||||
#user p {
|
||||
text-align: right;
|
||||
padding-right:0.5em;
|
||||
font-size: .8em;
|
||||
line-height: 2.0em;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
@@ -4,55 +4,84 @@
|
||||
|
||||
<h1 class="header-title text-center text-md-left py-4">
|
||||
<span class="f1-light text-gray-light">
|
||||
Comparing versions of
|
||||
{{t.comparing_versions_of}}
|
||||
</span>
|
||||
{{name}}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
{{#message}}
|
||||
<p>{{message}}</p>
|
||||
<p>{{message}}</p>
|
||||
{{/message}}
|
||||
|
||||
<div id="compare-content">
|
||||
<div id="compare-content">
|
||||
|
||||
<div class="py-4" id="actions">
|
||||
{{#show_revert}}
|
||||
{{#allow_editing}}
|
||||
<form name="gollum-revert" action="{{revert_path}}/{{escaped_url_path}}/{{before}}/{{after}}" method="post" id="gollum-revert-form"></form>
|
||||
<span class="pb-4">
|
||||
<button class="btn btn-sm" type="submit" onclick="$('#gollum-revert-form').submit()">Revert Changes</button>
|
||||
</span>
|
||||
{{/allow_editing}}
|
||||
{{/show_revert}}
|
||||
<a href="{{history_path}}/{{escaped_url_path}}" class="btn btn-sm action-page-history">Back to Page History</a>
|
||||
</div>
|
||||
<div class="py-4" id="actions">
|
||||
{{#show_revert}}
|
||||
{{#allow_editing}}
|
||||
<form name="gollum-revert" action="{{revert_path}}/{{escaped_url_path}}/{{before}}/{{after}}" method="post" id="gollum-revert-form"></form>
|
||||
<span class="pb-4">
|
||||
<button
|
||||
class="btn btn-sm"
|
||||
onclick="$('#gollum-revert-form').submit()"
|
||||
type="submit"
|
||||
>
|
||||
{{t.revert}}
|
||||
</button>
|
||||
</span>
|
||||
{{/allow_editing}}
|
||||
{{/show_revert}}
|
||||
|
||||
<div class="Box data highlight">
|
||||
<div class="Box-header Box--condensed Box-header--gray">{{path}} <span class="px-2 float-right">Comparing {{before}} to {{after}}</span></div>
|
||||
<table >
|
||||
{{#lines}}
|
||||
<tr>
|
||||
<td class="line_numbers">{{ldln}}</td>
|
||||
<td class="line_numbers">{{rdln}}</td>
|
||||
<td>
|
||||
<div class="{{class}} pl-2">{{line}}</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{/lines}}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<a
|
||||
class="btn btn-sm action-page-history"
|
||||
href="{{history_path}}/{{escaped_url_path}}"
|
||||
>
|
||||
{{t.back_to_page_history}}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="pt-4" id="footer">
|
||||
{{#show_revert}}
|
||||
{{#allow_editing}}
|
||||
<span class="pt-4"><button class="btn btn-sm gollum-revert-button" type="submit" onclick="$('#gollum-revert-form').submit()">Revert Changes</button></span>
|
||||
{{/allow_editing}}
|
||||
{{/show_revert}}
|
||||
<div class="pt-4">
|
||||
<a href="#">Back to Top</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Box data highlight">
|
||||
<div class="Box-header Box--condensed Box-header--gray">
|
||||
{{path}}
|
||||
|
||||
<span class="px-2 float-right">
|
||||
{{t.comparing_from}}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
{{#lines}}
|
||||
<tr>
|
||||
<td class="line_numbers">{{ldln}}</td>
|
||||
<td class="line_numbers">{{rdln}}</td>
|
||||
<td>
|
||||
<div class="{{class}} pl-2">{{line}}</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{/lines}}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pt-4" id="footer">
|
||||
{{#show_revert}}
|
||||
{{#allow_editing}}
|
||||
<span class="pt-4">
|
||||
<button
|
||||
class="btn btn-sm gollum-revert-button"
|
||||
onclick="$('#gollum-revert-form').submit()"
|
||||
type="submit"
|
||||
>
|
||||
{{t.revert}}
|
||||
</button>
|
||||
</span>
|
||||
{{/allow_editing}}
|
||||
{{/show_revert}}
|
||||
|
||||
<div class="pt-4">
|
||||
<a href="#">
|
||||
{{t.back_to_top}}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<div id="wiki-wrapper" class="error">
|
||||
<div id="error">
|
||||
<h1>Error</h1>
|
||||
<h1>{{t.error}}</h1>
|
||||
<p>
|
||||
{{message}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<h1 class="header-title text-center text-md-left py-4">
|
||||
<span class="f1-light text-gray-light">
|
||||
History for
|
||||
{{t.history_for}}
|
||||
</span>
|
||||
{{name}}
|
||||
</h1>
|
||||
@@ -14,32 +14,41 @@
|
||||
|
||||
{{>pagination}}
|
||||
|
||||
<form name="selection-form" id="selection-form" method="get" action="{{compare_path}}/{{escaped_url_path}}"></form>
|
||||
<form name="selection-form" id="selection-form" method="get" action="{{compare_path}}/{{escaped_url_path}}"></form>
|
||||
|
||||
<div id="page-history-list" class="Box Box--condensed flex-auto">
|
||||
<form id="version-form">
|
||||
<ul>
|
||||
{{#versions}}
|
||||
<li class="Box-row border-top Box-row--hover-gray d-flex flex-items-center">
|
||||
<span class="pr-2"><input class="checkbox" type="checkbox" name="versions[]" value="{{id}}"></span>
|
||||
<span class="float-left col-2" id="user-icons">{{>author_template}}</span>
|
||||
<time class="flex-auto col-1 text-gray-light" datetime="{{datetime}}" data-format="{{date_format}}">{{date}}</time>
|
||||
<span class="flex-auto col-5">{{message}}</span>
|
||||
<span class="pl-4 float-right">
|
||||
<a href="{{href}}" class="btn btn-outline text-mono">{{id7}}</a>
|
||||
<a href="{{href_page}}" title="Browse the page at this point in the history" class="btn btn-outline">{{#octicon}}code{{/octicon}}</a>
|
||||
</span>
|
||||
</li>
|
||||
{{/versions}}
|
||||
</ul>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="page-history-list" class="Box Box--condensed flex-auto">
|
||||
<form id="version-form">
|
||||
<ul>
|
||||
{{#versions}}
|
||||
<li class="Box-row border-top Box-row--hover-gray d-flex flex-items-center">
|
||||
<span class="pr-2"><input class="checkbox" type="checkbox" name="versions[]" value="{{id}}"></span>
|
||||
<span class="float-left col-2" id="user-icons">{{>author_template}}</span>
|
||||
<time class="flex-auto col-1 text-gray-light" datetime="{{datetime}}" data-format="{{date_format}}">{{date}}</time>
|
||||
<span class="flex-auto col-5">{{message}}</span>
|
||||
<span class="pl-4 float-right">
|
||||
<a href="{{href}}" class="btn btn-outline text-mono">{{id7}}</a>
|
||||
<a
|
||||
class="btn btn-outline"
|
||||
href="{{href_page}}"
|
||||
title="{{t.browse_in_history_description}}"
|
||||
>
|
||||
{{#octicon}}code{{/octicon}}
|
||||
</a>
|
||||
</span>
|
||||
</li>
|
||||
{{/versions}}
|
||||
</ul>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<div class="pt-4">
|
||||
<button class="btn btn-sm action-compare-revision" type="submit">Compare Revisions</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<div class="pt-4">
|
||||
<button
|
||||
class="btn btn-sm action-compare-revision"
|
||||
type="submit"
|
||||
>
|
||||
{{t.compare_revisions}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
<body>
|
||||
<div class="container-lg clearfix">
|
||||
{{{yield}}}
|
||||
{{< user}}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -21,25 +21,38 @@
|
||||
<span class="pr-2">{{{icon}}}</span>
|
||||
<span><a href="{{url}}">{{name}}</a></span>
|
||||
{{#allow_editing}}
|
||||
{{#is_file}}<button class="btn btn-sm float-right delete-file" data-file-path="{{file_path}}" data-confirm="Are you sure you want to delete {{name}}?">{{#octicon}}trash{{/octicon}}</button>{{/is_file}}
|
||||
{{/allow_editing}}
|
||||
{{#is_file}}
|
||||
<button
|
||||
class="btn btn-sm float-right delete-file"
|
||||
data-confirm="{{t.delete_confirmation}}"
|
||||
data-file-path="{{file_path}}"
|
||||
>
|
||||
{{#octicon}}trash{{/octicon}}
|
||||
</button>
|
||||
{{/is_file}}
|
||||
{{/allow_editing}}
|
||||
</li>
|
||||
{{/files_folders}}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
{{/has_results}}
|
||||
|
||||
{{#no_results}}
|
||||
<p id="no-results">
|
||||
There are no pages in <strong>{{current_path}}</strong> on <strong>{{ref}}</strong>.
|
||||
{{t.no_pages_in}}
|
||||
<strong>{{current_path}}</strong>
|
||||
{{t.on}}
|
||||
<strong>{{ref}}</strong>.
|
||||
</p>
|
||||
{{/no_results}}
|
||||
|
||||
</div>
|
||||
<div class="pt-4" id="footer">
|
||||
<a href="#">Back to Top</a>
|
||||
<a href="#">
|
||||
{{t.back_to_top}}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
<nav class="paginate-container" aria-label="Pagination">
|
||||
<nav class="paginate-container" aria-label="{{tt.pagination.aria.label}}">
|
||||
<div class="pagination" id="pagination">
|
||||
<a id="prev" href="?page_num={{previous_page}}{{query_string}}" class="previous_page {{^previous_page}}disabled{{/previous_page}}">Previous</span>
|
||||
<a id="next" href="?page_num={{next_page}}{{query_string}}" class="next_page {{^next_page}}disabled{{/next_page}}" rel="next" aria-label="Next Page">Next</a>
|
||||
<a
|
||||
aria-label="{{td.pagination.aria.previous_page}}"
|
||||
class="previous_page {{^previous_page}}disabled{{/previous_page}}"
|
||||
href="?page_num={{previous_page}}{{query_string}}"
|
||||
id="prev"
|
||||
rel="prev"
|
||||
>
|
||||
{{tt.pagination.previous}}
|
||||
</a>
|
||||
|
||||
<a
|
||||
aria-label="{{td.pagination.aria.next_page}}"
|
||||
class="next_page {{^next_page}}disabled{{/next_page}}"
|
||||
href="?page_num={{next_page}}{{query_string}}"
|
||||
id="next"
|
||||
rel="next"
|
||||
>
|
||||
{{tt.pagination.next}}
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
</nav>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<h1 class="header-title text-center text-md-left py-4">
|
||||
<span class="f1-light text-gray-light">
|
||||
Search results for
|
||||
{{t.search_results_for}}
|
||||
</span>
|
||||
{{name}}
|
||||
</h1>
|
||||
@@ -21,7 +21,12 @@
|
||||
<li class="Box-row Box-row--gray">
|
||||
<span class="Counter Counter--gray tooltipped tooltipped-w" aria-label="{{filename_count}} hits in filename - {{count}} hits in content">{{filename_count}} - {{count}}</span>
|
||||
<span class="text-bold"><a href="{{href}}">{{name}}</a></span>
|
||||
<button class="btn-link tooltipped tooltipped-w float-right toggle-context" aria-label="Show all {{count}} hits in this page">{{#octicon}}search{{/octicon}}</button>
|
||||
<button
|
||||
class="btn-link tooltipped tooltipped-w float-right toggle-context"
|
||||
aria-label="{{t.aria.show_all}}"
|
||||
>
|
||||
{{#octicon}}search{{/octicon}}
|
||||
</button>
|
||||
</li>
|
||||
|
||||
<div class="search-context">
|
||||
@@ -29,7 +34,6 @@
|
||||
<li class="Box-row border-0"><span class="text-italic">{{.}}</span></li>
|
||||
{{/context}}
|
||||
</div>
|
||||
|
||||
{{/results}}
|
||||
</ul>
|
||||
</div>
|
||||
@@ -37,12 +41,12 @@
|
||||
|
||||
{{#no_results}}
|
||||
<p id="no-results">
|
||||
There are no results for your search <strong>{{query}}</strong>.
|
||||
{{t.no_results}} <strong>{{query}}</strong>.
|
||||
</p>
|
||||
{{/no_results}}
|
||||
|
||||
<div id="footer" class="mt-4">
|
||||
<a class="btn" href="#">Back to Top</a>
|
||||
<a class="btn" href="#">{{t.back_to_top}}</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -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>
|
||||
@@ -6,7 +6,7 @@ module Precious
|
||||
attr_reader :page, :diff, :versions, :message, :allow_editing
|
||||
|
||||
def title
|
||||
"Comparison of #{@page.title}"
|
||||
[t[:comparison_of], @page.title].join(" ")
|
||||
end
|
||||
|
||||
def before
|
||||
|
||||
@@ -21,6 +21,13 @@ module Precious
|
||||
autofill I18n.t(locale_klass_name)
|
||||
end
|
||||
|
||||
# Returns all I18n translation strings from the root of an I18n YAML file.
|
||||
# Otherwise, it works exactly like the `#t` method that's also defined in
|
||||
# this file.
|
||||
def tt
|
||||
autofill I18n.t('.')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Recursively looks up I18n translation values and autofills any YAML
|
||||
|
||||
@@ -9,7 +9,7 @@ module Precious
|
||||
attr_reader :wiki
|
||||
|
||||
def title
|
||||
"Latest Changes (Globally)"
|
||||
t[:title]
|
||||
end
|
||||
|
||||
def versions
|
||||
|
||||
@@ -20,7 +20,7 @@ module Precious
|
||||
end
|
||||
|
||||
def title
|
||||
"Home"
|
||||
t[:title]
|
||||
end
|
||||
|
||||
def has_path
|
||||
@@ -58,11 +58,11 @@ module Precious
|
||||
def js # custom js
|
||||
@js
|
||||
end
|
||||
|
||||
|
||||
def critic_markup
|
||||
@critic_markup
|
||||
end
|
||||
|
||||
|
||||
def per_page_uploads
|
||||
@per_page_uploads
|
||||
end
|
||||
@@ -75,32 +75,19 @@ module Precious
|
||||
def search
|
||||
false
|
||||
end
|
||||
|
||||
|
||||
def history
|
||||
false
|
||||
end
|
||||
|
||||
|
||||
def overview
|
||||
false
|
||||
end
|
||||
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
@@ -3,11 +3,11 @@ require 'pathname'
|
||||
module Precious
|
||||
module Views
|
||||
class Overview < Layout
|
||||
attr_reader :results, :ref, :allow_editing, :newable
|
||||
attr_reader :name, :results, :ref, :allow_editing, :newable
|
||||
HIDDEN_PATHS = ['.gitkeep']
|
||||
|
||||
def title
|
||||
"Overview of #{@ref}"
|
||||
t[:title]
|
||||
end
|
||||
|
||||
# def editable
|
||||
@@ -38,21 +38,21 @@ module Precious
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def files_folders
|
||||
if has_results
|
||||
files_and_folders = []
|
||||
|
||||
|
||||
@results.each do |result|
|
||||
result_path = result.url_path
|
||||
result_path = result_path.sub(/^#{Regexp.escape(@path)}\//, '') unless @path.nil?
|
||||
result_path = result_path.sub(/^#{Regexp.escape(@path)}\//, '') unless @path.nil?
|
||||
if result_path.include?('/')
|
||||
# result contains a folder
|
||||
folder_name = result_path.split('/').first
|
||||
folder_path = @path ? "#{@path}/#{folder_name}" : folder_name
|
||||
folder_url = "#{overview_path}/#{folder_path}/"
|
||||
files_and_folders << {name: folder_name, icon: rocticon('file-directory'), type: 'dir', url: folder_url, is_file: false}
|
||||
elsif !HIDDEN_PATHS.include?(result_path)
|
||||
elsif !HIDDEN_PATHS.include?(result_path)
|
||||
file_url = page_route(result.escaped_url_path)
|
||||
files_and_folders << {name: result.filename, icon: rocticon('file'), type: 'file', url: file_url, file_path: result.escaped_url_path, is_file: true}
|
||||
end
|
||||
@@ -61,7 +61,7 @@ module Precious
|
||||
files_and_folders.uniq{|f| f[:name]}.sort_by!{|f| [f[:type], f[:name]]}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def has_results
|
||||
!@results.empty?
|
||||
@@ -70,12 +70,12 @@ module Precious
|
||||
def no_results
|
||||
@results.empty?
|
||||
end
|
||||
|
||||
|
||||
def latest_changes
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,4 +10,4 @@ module Precious
|
||||
@page_num == 1 ? nil : (@page_num - 1).to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@ module Precious
|
||||
end
|
||||
|
||||
def title
|
||||
"Search results for " + @query
|
||||
t[:title]
|
||||
end
|
||||
|
||||
def search
|
||||
|
||||
@@ -15,12 +15,13 @@ describe Precious::Views::LocaleHelpers do
|
||||
end
|
||||
|
||||
def setup
|
||||
::I18n.available_locales = [:en, :de]
|
||||
::I18n.load_path = Dir[File.expand_path("test/support/locales" + "/*.yml")]
|
||||
I18n.available_locales = [:en, :de]
|
||||
I18n.load_path = Dir[File.expand_path("test/support/locales" + "/*.yml")]
|
||||
end
|
||||
|
||||
def teardown
|
||||
I18n.locale = :en
|
||||
I18n.load_path = Dir[::File.expand_path("lib/gollum/locales") + "/*.yml"]
|
||||
end
|
||||
|
||||
let(:dummy_instance) { TestClass.new }
|
||||
@@ -131,4 +132,99 @@ describe Precious::Views::LocaleHelpers do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#tt" do
|
||||
describe "mustache usage" do
|
||||
let(:subject) { dummy_instance.render(mustache_template) }
|
||||
|
||||
let(:mustache_template) { "{{ tt.test_class.hello_world }}" }
|
||||
|
||||
describe "in the default locale" do
|
||||
it "returns the translation string" do
|
||||
_(subject).must_equal "Hello world"
|
||||
end
|
||||
end
|
||||
|
||||
describe "in the configured locale" do
|
||||
it "returns the translation string" do
|
||||
I18n.locale = :de
|
||||
|
||||
_(subject).must_equal "Hallo Welt"
|
||||
end
|
||||
end
|
||||
|
||||
describe "translations with YAML arguments" do
|
||||
let(:mustache_template) { "{{ tt.test_class.author_info.full }}" }
|
||||
|
||||
describe "in the default locale" do
|
||||
it "autofills YAML arguments" do
|
||||
_(subject).must_equal "Author J.R.R. is from Bloemfontein"
|
||||
end
|
||||
end
|
||||
|
||||
describe "in the configured locale" do
|
||||
it "autofills YAML arguments" do
|
||||
I18n.locale = :de
|
||||
|
||||
_(subject).must_equal "Autor J.R.R. ist vom Bloemfontein"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "translations with invalid arguments" do
|
||||
let(:mustache_template) { "{{ tt.test_class.has_invalid_argument }}" }
|
||||
|
||||
it "fails gracefully with embedded error message" do
|
||||
expected_string = "Welcome to " \
|
||||
"[#{TestClass::NO_METHOD_MESSAGE}: no_matching_method]"
|
||||
|
||||
_(subject).must_equal expected_string
|
||||
end
|
||||
end
|
||||
|
||||
describe "missing translations" do
|
||||
let(:mustache_template) {
|
||||
"{{ tt.test_class.nested.nonexistent_key }}"
|
||||
}
|
||||
|
||||
it "outputs an empty string" do
|
||||
_(subject).must_be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "usage" do
|
||||
let(:subject) { dummy_instance.tt }
|
||||
|
||||
it "returns a hash" do
|
||||
_(subject).must_be_kind_of Hash
|
||||
end
|
||||
|
||||
it "returns all present translation keys" do
|
||||
i18n_keys = I18n.t(".").keys
|
||||
|
||||
_(subject.keys).must_equal i18n_keys
|
||||
end
|
||||
|
||||
it "returns nested keys" do
|
||||
nested_keys = subject[:test_class][:author_info].keys
|
||||
|
||||
_(nested_keys).must_equal [:full]
|
||||
end
|
||||
|
||||
describe "auto-filled YAML arguments" do
|
||||
let(:subject) { dummy_instance.tt[:test_class][:author_info][:full] }
|
||||
|
||||
it "auto-fills in the default locale" do
|
||||
_(subject).must_equal "Author J.R.R. is from Bloemfontein"
|
||||
end
|
||||
|
||||
it "auto-fills in a configured locale" do
|
||||
I18n.locale = :de
|
||||
|
||||
_(subject).must_equal "Autor J.R.R. ist vom Bloemfontein"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+3
-17
@@ -477,9 +477,9 @@ EOF
|
||||
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\r"
|
||||
temp_upload_file = Tempfile.new(['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' => 'http://localhost:4567/Home.md', 'HTTP_HOST' => 'localhost:4567'}
|
||||
@@ -488,21 +488,7 @@ EOF
|
||||
@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\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
|
||||
assert_equal 'abc', file.raw_data
|
||||
Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false})
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user