Compare commits

...

4 Commits

Author SHA1 Message Date
benjamin wil e87142ef19 Explicitly set encoding for Precious::App
An issue was reported (see #1721) where, in docker containers where the
`LANG` was not being set, `Precious::App` would serve Mustache templates
in an ASCII encoding. This caused templates to error out.

In the past, this would have happened in environments where `LANG` was
not set and the Gollum applciation configuration had enabled MathJax.
Now, it happens even if MathJax is disabled because of a UTF-8 character
I added to the mobile navigation menu.

Basically, we should enforce a UTF-8 encoding from now on to avoid
runtime errors related to ASCII encoding.
2021-06-13 14:24:26 -07:00
benjamin wil aa823b5a2d Use recent JRuby release for Travis CI (#1730)
Our JRuby CI runs have been errorring due to what I think is an issue
with an older `jruby-openssl` version.
2021-06-13 14:17:18 -07:00
Dawa Ometto 9012dee888 Release 5.2.3 2021-04-18 13:43:00 +02:00
benjamin wil 81d5f1a8bb Ensure <title> is rendered for pages (#1710)
I made a mistake when I made `#title` a private method. I did not see
that it was being called from `layout.mustache` to generate the
`<title></title>` tag in the `<head></head>` of each page.

This fixes my error, and adds tests so the behaviour is more explicit.
2021-04-05 09:26:50 -07:00
7 changed files with 54 additions and 23 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ rvm:
- 2.4.0 - 2.4.0
- 2.6.0 - 2.6.0
- 3.0.0 - 3.0.0
- jruby-9.2.9.0 - jruby-9.2.18.0
jdk: jdk:
- oraclejdk9 - oraclejdk9
before_install: before_install:
+4
View File
@@ -1,3 +1,7 @@
# 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. * Fix include call to a missing asset (@benjaminwil). This caused slow first page loads on JRuby.
+2 -2
View File
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 1.9' s.required_ruby_version = '>= 1.9'
s.name = 'gollum' s.name = 'gollum'
s.version = '5.2.2' s.version = '5.2.3'
s.date = '2021-03-27' s.date = '2021-04-18'
s.license = 'MIT' s.license = 'MIT'
s.summary = 'A simple, Git-powered wiki.' s.summary = 'A simple, Git-powered wiki.'
+1 -1
View File
@@ -12,7 +12,7 @@ require 'rhino' if RUBY_PLATFORM == 'java'
require File.expand_path('../gollum/uri_encode_component', __FILE__) require File.expand_path('../gollum/uri_encode_component', __FILE__)
module Gollum module Gollum
VERSION = '5.2.2' VERSION = '5.2.3'
def self.assets_path def self.assets_path
::File.expand_path('gollum/public', ::File.dirname(__FILE__)) ::File.expand_path('gollum/public', ::File.dirname(__FILE__))
+4 -1
View File
@@ -1,4 +1,5 @@
# ~*~ encoding: utf-8 ~*~ # encoding: UTF-8
require 'cgi' require 'cgi'
require 'sinatra' require 'sinatra'
require 'sinatra/namespace' require 'sinatra/namespace'
@@ -69,6 +70,8 @@ module Precious
register Sinatra::Namespace register Sinatra::Namespace
include Precious::Helpers include Precious::Helpers
Encoding.default_external = "UTF-8"
dir = File.dirname(File.expand_path(__FILE__)) dir = File.dirname(File.expand_path(__FILE__))
set :sprockets, ::Precious::Assets.sprockets(dir) set :sprockets, ::Precious::Assets.sprockets(dir)
+5 -5
View File
@@ -16,6 +16,11 @@ module Precious
DEFAULT_AUTHOR = 'you' DEFAULT_AUTHOR = 'you'
@@to_xml = { :save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML ^ 1, :indent => 0, :encoding => 'UTF-8' } @@to_xml = { :save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML ^ 1, :indent => 0, :encoding => 'UTF-8' }
def title
h1 = @h1_title ? page_header_from_content(@content) : false
h1 || @page.url_path_title # url_path_title is the metadata title if present, otherwise the filename-based title
end
def page_header def page_header
title title
end end
@@ -263,11 +268,6 @@ module Precious
end end
result << "</tr>\n</table>\n" result << "</tr>\n</table>\n"
end end
def title
h1 = @h1_title ? page_header_from_content(@content) : false
h1 || @page.url_path_title # url_path_title is the metadata title if present, otherwise the filename-based title
end
end end
end end
end end
+25 -1
View File
@@ -38,7 +38,31 @@ context "Precious::Views::Page" do
assert_include @view.breadcrumb, "数学 📘" assert_include @view.breadcrumb, "数学 📘"
end end
test "page header retains unicde and ASCII characters" do test 'page <title> is the page header from content, if present' do
page_title = 'Page header from content'
@wiki.write_page(page_title, :markdown, 'Contents', commit_details)
@view = Precious::Views::Page.new.tap do |view|
view.instance_variable_set :@page, @wiki.page(page_title)
view.instance_variable_set :@h1_title, true
end
assert_equal @view.title, 'Page header from content'
end
test 'page <title> is URL path title if no h1 present' do
@wiki.write_page('dir/My path title', :markdown, 'Contents', commit_details)
page = @wiki.page('dir/My path title')
@view = Precious::Views::Page.new.tap do |view|
view.instance_variable_set :@page, page
view.instance_variable_set :@h1_title, false
end
assert_equal @view.title, 'My path title'
end
test "page header retains unicode and ASCII characters" do
title = "数学 📘" title = "数学 📘"
@wiki.write_page(title, :markdown, "How old is Bilbo?") @wiki.write_page(title, :markdown, "How old is Bilbo?")
page = @wiki.page(title) page = @wiki.page(title)