Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9bc3baa1dc | |||
| 046353cf7e | |||
| 51f2f032d7 | |||
| 70360edb96 | |||
| 2b12ab9206 | |||
| 87a01e04ce | |||
| 5f04200bd0 | |||
| aa823b5a2d |
@@ -0,0 +1,29 @@
|
||||
name: Ruby Build
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
ruby: [2.4.0, 2.6.0, 3.0.0, jruby-9.2.18.0]
|
||||
steps:
|
||||
- run: echo "The job was automatically triggered by a ${{ github.event_name }} event."
|
||||
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub!"
|
||||
- run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v2
|
||||
- run: echo "The ${{ github.repository }} repository has been cloned to the runner."
|
||||
- run: echo "The workflow is now ready to test your code on the runner."
|
||||
- name: List files in the repository
|
||||
run: |
|
||||
ls ${{ github.workspace }}
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '9'
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby }}
|
||||
bundler-cache: true
|
||||
- name: exec rake
|
||||
run: bundle exec rake
|
||||
@@ -8,3 +8,4 @@ Gemfile.lock
|
||||
.*
|
||||
!.sprockets*
|
||||
!lib/gollum/public/gollum/stylesheets/_styles.css
|
||||
!.github*
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ rvm:
|
||||
- 2.4.0
|
||||
- 2.6.0
|
||||
- 3.0.0
|
||||
- jruby-9.2.9.0
|
||||
- jruby-9.2.18.0
|
||||
jdk:
|
||||
- oraclejdk9
|
||||
before_install:
|
||||
|
||||
@@ -2,10 +2,11 @@ gollum -- A git-based Wiki
|
||||
====================================
|
||||
|
||||
[](http://badge.fury.io/rb/gollum)
|
||||
[](https://travis-ci.org/gollum/gollum)
|
||||

|
||||
[](https://www.codetriage.com/gollum/gollum)
|
||||
[](https://dometto-cuttingedge.herokuapp.com/github/gollum/gollum/info)
|
||||
|
||||
|
||||
**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
|
||||
@@ -45,7 +46,7 @@ Installation examples for individual systems can be seen [here](https://github.c
|
||||
|
||||
To run, simply:
|
||||
|
||||
1. Run: `gollum /path/to/wiki`.
|
||||
1. Run: `gollum /path/to/wiki` where `/path/to/wiki` is an initialized Git repository.
|
||||
2. Open `http://localhost:4567` in your browser.
|
||||
|
||||
See [below](#running-from-source) for information on running Gollum from source, as a Rack app, and more.
|
||||
|
||||
@@ -39,6 +39,7 @@ Gem::Specification.new do |s|
|
||||
s.add_dependency 'rss', '~> 0.2.9'
|
||||
s.add_dependency 'therubyrhino', '~> 2.1.0'
|
||||
s.add_dependency 'webrick', '~> 1.7'
|
||||
s.add_dependency 'i18n', '~> 1.8'
|
||||
|
||||
s.add_development_dependency 'rack-test', '~> 0.6.3'
|
||||
s.add_development_dependency 'shoulda', '~> 3.6.0'
|
||||
|
||||
+5
-2
@@ -5,15 +5,19 @@ require 'digest/sha1'
|
||||
require 'ostruct'
|
||||
|
||||
# external
|
||||
require 'i18n'
|
||||
require 'github/markup'
|
||||
require 'rhino' if RUBY_PLATFORM == 'java'
|
||||
|
||||
# internal
|
||||
require File.expand_path('../gollum/uri_encode_component', __FILE__)
|
||||
require ::File.expand_path('../gollum/uri_encode_component', __FILE__)
|
||||
|
||||
module Gollum
|
||||
VERSION = '5.2.3'
|
||||
|
||||
::I18n.available_locales = [:en]
|
||||
::I18n.load_path = Dir[::File.expand_path("lib/gollum/locales") + "/*.yml"]
|
||||
|
||||
def self.assets_path
|
||||
::File.expand_path('gollum/public', ::File.dirname(__FILE__))
|
||||
end
|
||||
@@ -32,5 +36,4 @@ module Gollum
|
||||
data
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
+8
-4
@@ -1,4 +1,5 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
# encoding: UTF-8
|
||||
|
||||
require 'cgi'
|
||||
require 'sinatra'
|
||||
require 'sinatra/namespace'
|
||||
@@ -14,6 +15,7 @@ require 'pathname'
|
||||
require 'gollum'
|
||||
require 'gollum/assets'
|
||||
require 'gollum/views/helpers'
|
||||
require 'gollum/views/helpers/locale_helpers'
|
||||
require 'gollum/views/layout'
|
||||
require 'gollum/views/editable'
|
||||
require 'gollum/views/has_page'
|
||||
@@ -69,6 +71,8 @@ module Precious
|
||||
register Sinatra::Namespace
|
||||
include Precious::Helpers
|
||||
|
||||
Encoding.default_external = "UTF-8"
|
||||
|
||||
dir = File.dirname(File.expand_path(__FILE__))
|
||||
|
||||
set :sprockets, ::Precious::Assets.sprockets(dir)
|
||||
@@ -406,7 +410,7 @@ module Precious
|
||||
else
|
||||
sha2, sha1 = sha1, "#{sha1}^" if !sha2
|
||||
@versions = [sha1, sha2]
|
||||
@diff = wiki.repo.diff(@versions.first, @versions.last, @page.path)
|
||||
@diff = wiki.repo.diff(@versions.first, @versions.last, @page.path).force_encoding('utf-8')
|
||||
@message = 'The patch does not apply.'
|
||||
mustache :compare
|
||||
end
|
||||
@@ -471,7 +475,7 @@ module Precious
|
||||
@versions = [start_version, end_version]
|
||||
wiki = wikip.wiki
|
||||
@page = wikip.page
|
||||
@diff = wiki.repo.diff(@versions.first, @versions.last, @page.path)
|
||||
@diff = wiki.repo.diff(@versions.first, @versions.last, @page.path).force_encoding('utf-8')
|
||||
if @diff.empty?
|
||||
@message = 'Could not compare these two revisions, no differences were found.'
|
||||
mustache :error
|
||||
@@ -515,7 +519,7 @@ module Precious
|
||||
@commit = wiki.repo.commit(version)
|
||||
parent = @commit.parent
|
||||
parent_id = parent.nil? ? nil : parent.id
|
||||
@diff = wiki.repo.diff(parent_id, version)
|
||||
@diff = wiki.repo.diff(parent_id, version).force_encoding('utf-8')
|
||||
mustache :commit
|
||||
rescue Gollum::Git::NoSuchShaFound
|
||||
@message = "Invalid commit: #{@version}"
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"files":{"app-0fd228e26bfbe6fe31a2da268eb0e98e780c1191c1a918adf383377946e9c838.js":{"logical_path":"app.js","mtime":"2021-03-23T08:40:11-07:00","size":136020,"digest":"0fd228e26bfbe6fe31a2da268eb0e98e780c1191c1a918adf383377946e9c838","integrity":"sha256-D9Io4mv75v4xotomjrDpjngMEZHBqRit84M3eUbpyDg="},"editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js":{"logical_path":"editor.js","mtime":"2021-02-24T23:16:14-08:00","size":744866,"digest":"db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf","integrity":"sha256-2xDINRMG6S8ZJroiXQzZyOiGSCs7mCCoWCXsOrq18c8="},"app-ad43ca64b295d8444b10f22ee868f18429268af498f1bc515434878b690e37a2.css":{"logical_path":"app.css","mtime":"2021-03-23T08:40:11-07:00","size":396615,"digest":"ad43ca64b295d8444b10f22ee868f18429268af498f1bc515434878b690e37a2","integrity":"sha256-rUPKZLKV2ERLEPIu6GjxhCkmivSY8bxRVDSHi2kON6I="},"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css":{"logical_path":"criticmarkup.css","mtime":"2021-02-24T23:16:14-08:00","size":646,"digest":"31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4","integrity":"sha256-Ma5dMoK7uOe3w8mRfp+2jjMVprSnXabOxI0huIRpBcQ="},"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css":{"logical_path":"print.css","mtime":"2021-02-24T23:16:14-08:00","size":75,"digest":"512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb","integrity":"sha256-USSYw2i+DT+xuhBd+oQomuSDgOyfy++Ui9TiOwsJW/s="}},"assets":{"app.js":"app-0fd228e26bfbe6fe31a2da268eb0e98e780c1191c1a918adf383377946e9c838.js","editor.js":"editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js","app.css":"app-ad43ca64b295d8444b10f22ee868f18429268af498f1bc515434878b690e37a2.css","criticmarkup.css":"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css","print.css":"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css"}}
|
||||
{"files":{"app-0fd228e26bfbe6fe31a2da268eb0e98e780c1191c1a918adf383377946e9c838.js":{"logical_path":"app.js","mtime":"2021-07-08T06:42:59+09:00","size":136020,"digest":"0fd228e26bfbe6fe31a2da268eb0e98e780c1191c1a918adf383377946e9c838","integrity":"sha256-D9Io4mv75v4xotomjrDpjngMEZHBqRit84M3eUbpyDg="},"editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js":{"logical_path":"editor.js","mtime":"2021-07-08T05:19:03+09:00","size":744866,"digest":"db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf","integrity":"sha256-2xDINRMG6S8ZJroiXQzZyOiGSCs7mCCoWCXsOrq18c8="},"app-cb122b4c17500faa5e013cb43334fafcf2dd7d72f694b06d9616f8b33fefb694.css":{"logical_path":"app.css","mtime":"2021-07-08T06:42:59+09:00","size":396625,"digest":"cb122b4c17500faa5e013cb43334fafcf2dd7d72f694b06d9616f8b33fefb694","integrity":"sha256-yxIrTBdQD6peATy0MzT6/PLdfXL2lLBtlhb4sz/vtpQ="},"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css":{"logical_path":"criticmarkup.css","mtime":"2021-07-08T05:19:03+09:00","size":646,"digest":"31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4","integrity":"sha256-Ma5dMoK7uOe3w8mRfp+2jjMVprSnXabOxI0huIRpBcQ="},"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css":{"logical_path":"print.css","mtime":"2021-07-08T05:19:03+09:00","size":75,"digest":"512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb","integrity":"sha256-USSYw2i+DT+xuhBd+oQomuSDgOyfy++Ui9TiOwsJW/s="}},"assets":{"app.js":"app-0fd228e26bfbe6fe31a2da268eb0e98e780c1191c1a918adf383377946e9c838.js","editor.js":"editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js","app.css":"app-cb122b4c17500faa5e013cb43334fafcf2dd7d72f694b06d9616f8b33fefb694.css","criticmarkup.css":"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css","print.css":"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css"}}
|
||||
BIN
Binary file not shown.
+1
-1
File diff suppressed because one or more lines are too long
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -29,6 +29,7 @@ a.tabnav-tab:focus {
|
||||
overflow: hidden;
|
||||
font-family: Consolas, "Liberation Mono", Courier, monospace;
|
||||
font-size: 1em;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#gollum-editor {
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
module Precious
|
||||
module Views
|
||||
module LocaleHelpers
|
||||
NO_METHOD_MESSAGE = 'Argument must be a view method'
|
||||
YAML_VARIABLE_REGEXP = /\%\{[\w]+\}/
|
||||
|
||||
# Returns all I18n translation strings for the current view class.
|
||||
# This method support YAML arguments. For example:
|
||||
#
|
||||
# last_edited: This content was last edited at %{date}.
|
||||
#
|
||||
# Where the `date` argument must be a method available on the current
|
||||
# class.
|
||||
#
|
||||
# Use this interface within Mustache templates to render any user
|
||||
# interface strings in the current locale. For example:
|
||||
#
|
||||
# {{ t.last_edited }}
|
||||
#
|
||||
def t
|
||||
autofill I18n.t(locale_klass_name)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Recursively looks up I18n translation values and autofills any YAML
|
||||
# arguments with the return value of the current class's matching method.
|
||||
#
|
||||
# When a translation value with an argument has no matching method, we
|
||||
# then return that value transformed to include the `no_method_message`
|
||||
#
|
||||
def autofill(yaml)
|
||||
yaml.map { |i18n_key, i18n_value|
|
||||
if i18n_value.is_a? Hash
|
||||
[i18n_key, autofill(i18n_value)]
|
||||
elsif has_arguments?(i18n_value)
|
||||
fill_argument_content(i18n_key, i18n_value)
|
||||
else
|
||||
[i18n_key, i18n_value]
|
||||
end
|
||||
}.to_h
|
||||
end
|
||||
|
||||
def fill_argument_content(i18n_key, i18n_value)
|
||||
i18n_value.gsub!(YAML_VARIABLE_REGEXP) do |argument|
|
||||
method_name = argument.gsub(/[^\w]/, '')
|
||||
|
||||
next if method_name.nil?
|
||||
|
||||
begin
|
||||
self.public_send(method_name)
|
||||
rescue NoMethodError => error
|
||||
no_method_message(method_name)
|
||||
end
|
||||
end
|
||||
|
||||
[i18n_key, i18n_value]
|
||||
end
|
||||
|
||||
def has_arguments?(i18n_value)
|
||||
i18n_value.match?(YAML_VARIABLE_REGEXP)
|
||||
end
|
||||
|
||||
# Returns the current class name in a format that is acceptable in YAML.
|
||||
# To summarize its function:
|
||||
#
|
||||
# NameOfConstant => name_of_constant
|
||||
#
|
||||
def locale_klass_name
|
||||
@locale_klass_name ||= self.class.name.gsub(/::/, '/').
|
||||
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
||||
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
||||
tr('-', '_').
|
||||
downcase
|
||||
end
|
||||
|
||||
def no_method_message(method_name, message = NO_METHOD_MESSAGE)
|
||||
"[#{message}: #{method_name}]"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -6,6 +6,7 @@ module Precious
|
||||
include Rack::Utils
|
||||
include Sprockets::Helpers
|
||||
include Precious::Views::AppHelpers
|
||||
include Precious::Views::LocaleHelpers
|
||||
include Precious::Views::SprocketsHelpers
|
||||
include Precious::Views::RouteHelpers
|
||||
include Precious::Views::OcticonHelpers
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
require_relative "../../helper"
|
||||
require_relative "../../../lib/gollum/views/helpers"
|
||||
|
||||
describe Precious::Views::LocaleHelpers do
|
||||
class TestClass < Mustache
|
||||
include Precious::Views::LocaleHelpers
|
||||
|
||||
def author
|
||||
"J.R.R."
|
||||
end
|
||||
|
||||
def location
|
||||
"Bloemfontein"
|
||||
end
|
||||
end
|
||||
|
||||
def setup
|
||||
::I18n.available_locales = [:en, :de]
|
||||
::I18n.load_path = Dir[File.expand_path("test/support/locales" + "/*.yml")]
|
||||
end
|
||||
|
||||
def teardown
|
||||
I18n.locale = :en
|
||||
end
|
||||
|
||||
let(:dummy_instance) { TestClass.new }
|
||||
|
||||
describe "#t" do
|
||||
describe "mustache usage" do
|
||||
let(:subject) { dummy_instance.render(mustache_template) }
|
||||
|
||||
let(:mustache_template) { "{{ t.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) { "{{ t.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) { "{{ t.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 "out of scope translations" do
|
||||
let(:mustache_template) { "{{ t.never_called }}" }
|
||||
|
||||
it "does not include translation keys from other classes" do
|
||||
_(subject).must_be_empty
|
||||
end
|
||||
end
|
||||
|
||||
describe "missing translations" do
|
||||
let(:mustache_template) { "{{ t.nested.nonexistent_key }}" }
|
||||
|
||||
it "outputs an empty string" do
|
||||
_(subject).must_be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "usage" do
|
||||
let(:subject) { dummy_instance.t }
|
||||
|
||||
it "returns a hash" do
|
||||
_(subject).must_be_kind_of Hash
|
||||
end
|
||||
|
||||
it "returns translation keys under 'test_class'" do
|
||||
i18n_keys = I18n.t("test_class").keys
|
||||
|
||||
_(subject.keys).must_equal i18n_keys
|
||||
end
|
||||
|
||||
it "does not return translation keys under other classes" do
|
||||
other_i18n_keys = I18n.t("nonexistant_test_class").keys
|
||||
|
||||
_(subject.keys).wont_include other_i18n_keys
|
||||
end
|
||||
|
||||
it "returns nested keys" do
|
||||
nested_keys = subject[:author_info].keys
|
||||
|
||||
_(nested_keys).must_equal [:full]
|
||||
end
|
||||
|
||||
describe "auto-filled YAML arguments" do
|
||||
let(:subject) { dummy_instance.t[: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
|
||||
@@ -5,6 +5,7 @@ require 'shoulda'
|
||||
require 'mocha/setup'
|
||||
require 'fileutils'
|
||||
require 'minitest/reporters'
|
||||
require 'minitest/spec'
|
||||
require 'twitter_cldr'
|
||||
require 'tmpdir'
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
de:
|
||||
test_class:
|
||||
author_info:
|
||||
full: Autor %{author} ist vom %{location}
|
||||
has_invalid_argument: Willkommen in %{no_matching_method}
|
||||
hello_world: Hallo Welt
|
||||
nonexistant_test_class:
|
||||
never_called: Nie angerufen
|
||||
@@ -0,0 +1,8 @@
|
||||
en:
|
||||
test_class:
|
||||
author_info:
|
||||
full: Author %{author} is from %{location}
|
||||
has_invalid_argument: Welcome to %{no_matching_method}
|
||||
hello_world: Hello world
|
||||
nonexistant_test_class:
|
||||
never_called: Never called
|
||||
@@ -48,6 +48,15 @@ context "Frontend" do
|
||||
assert last_response.ok?
|
||||
end
|
||||
|
||||
test 'compare with utf8' do
|
||||
commit = { :name => 'user1', :email => 'user1' }
|
||||
@wiki.write_page('Utf8', :markdown, '\n中文', commit)
|
||||
page = @wiki.page('Utf8')
|
||||
@wiki.update_page(page, nil, nil, "No utf-8", commit)
|
||||
get "/gollum/compare/Utf8.md/#{page.versions.first.id}..#{page.versions.last.id}"
|
||||
assert last_response.body.include?('<div class="gi pl-2">+\n中文</div>')
|
||||
end
|
||||
|
||||
test "UTF-8 headers href preserved" do
|
||||
page = 'utfh1'
|
||||
text = nfd('한글')
|
||||
|
||||
@@ -44,7 +44,7 @@ def load_script(**args)
|
||||
end
|
||||
end
|
||||
|
||||
unless ENV['TRAVIS']
|
||||
unless ENV['CI']
|
||||
|
||||
context '4.x -> 5.x tag migrator' do
|
||||
include Rack::Test::Methods
|
||||
|
||||
Reference in New Issue
Block a user