Compare commits

...

10 Commits

Author SHA1 Message Date
benjamin wil 851f53194e Fix failing spec
My changes to the header layout seem to changed where the spaces in
`last_response.body` are placed. So let's assert only that the content
is present, since that's all this test should actually care about.
2021-12-30 14:30:20 -08:00
benjamin wil d3a709c4d3 Recompile assets 2021-12-30 14:30:20 -08:00
benjamin wil 0b75a47750 Adjust padding and presentation of mobile menu
To give mobile page headers more structure, this commit adjusts the
padding to be more symmetrical. It also adds a `border-bottom` on mobile
only. In my opinion this improves readability by telling the reader,
"This is where the navigation menu ends and the page content begins."
2021-12-30 14:30:20 -08:00
benjamin wil 4fcc72078b Use .header-title for all #head headings
This commit:

  1. Updates all main templates to use the new `.header-title` class,
     making these titles less disruptively large on mobile devices.
  2. Centers these titles for mobile breakpoints only, re-setting them
     back to left-aligned text for `md-` breakpoints and up.

Note that in `lib/gollum/templates/wiki_contentf.mustache`, the
`.header-title` is not a `#head .header-title`, so it doesn't inherit
all of the new styles added in this commit.
2021-12-30 14:30:20 -08:00
benjamin wil 9b4755e822 Add .header-title style
This style shows smaller text on mobile devices. It reverts back to the
`2em` size used in Primer for H1 tags.
2021-12-30 14:30:20 -08:00
benjamin wil 9c574fd760 Improve test suite and CI run performance (#1796)
* Simplify test

I came across this test because it was failing JRuby CI runs. I should
emphasize, though, that this test was only failing due do an upstream
bug in Nokogiri v1.12.5.

When I was reviewing the test, to understand why it was failing at all,
I noticed that the assertion was rather obfuscated.  Specifically, we
were post-processing the entire `response.body` and using that as an
expectation.

* Use an older version of Nokogiri in our test env

This is a temporary fix. See the commit diff for more information.

* Split JRuby CI runs from MRI CI runs

We can improve the performance of our MRI test runs by not installing
Java as part of their run. (Java is only required for JRuby.)

* Use latest Ruby patch versions during CI runs

* Simplify GitHub Action workflow steps

Judging by the output in the GitHub Actions workflow UI, the `echo`
steps were not providing much value to us.

We can get rid of them to slightly increase run performance.

I've also named the other steps to make it easier to skim the Actions
workflow output.

* Remove `twitter_cldr` development dependency

This is no longer being used.

* Change GitHub Actions workflow Ruby matrix

We can drop Ruby 2.4 from our test run matrix. It is beyond EOL.
Let's add 2.7 instead.
2021-12-30 14:21:23 -08:00
Dawa Ometto 46c22a8b87 Take account of possible https referer in upload route (#1787) 2021-12-23 12:18:30 +01:00
Ryan Govostes 7e379cfab1 Reduce size of container image (#1777)
* Reduce size of container image
* Add deprecation message for automatic --mathjax
2021-12-22 20:54:29 +01:00
Dawa Ometto 93d3d10453 Update gollum (#1786)
Exit with code 1 (error) when invalid option is given
2021-12-22 18:08:20 +01:00
fhchl 98a0006c86 Fix mathjax on edit and create pages (#1773)
* Fix mathjax on edit and create pages
2021-12-22 17:00:31 +01:00
32 changed files with 204 additions and 95 deletions
+2 -2
View File
@@ -34,5 +34,5 @@ jobs:
run: echo ${{ steps.docker_build.outputs.digest }} run: echo ${{ steps.docker_build.outputs.digest }}
- name: docker state - name: docker state
run: docker image ls run: docker image ls
- name: Run tests - name: Run gollum as test
run: docker run -e CI=true -w /app --entrypoint bundle ${{ env.CI_IMAGE }} exec rake run: docker run -e CI=true ${{ env.CI_IMAGE }} --irb
+27 -10
View File
@@ -1,29 +1,46 @@
name: Ruby Build name: Ruby Build
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
build: jruby_build:
name: JRuby (${{ matrix.ruby }})
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
ruby: [2.4.0, 2.6.0, 3.0.0, jruby-9.2.18.0] ruby: [jruby-9.2.18]
steps: 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 - name: Check out repository code
uses: actions/checkout@v2 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 - name: List files in the repository
run: | run: |
ls ${{ github.workspace }} ls ${{ github.workspace }}
- uses: actions/setup-java@v2 - name: Set up Java
uses: actions/setup-java@v2
with: with:
distribution: 'adopt' distribution: 'adopt'
java-version: '11' java-version: '11'
- uses: ruby/setup-ruby@v1 - name: Set up Ruby
uses: ruby/setup-ruby@v1
with: with:
ruby-version: ${{ matrix.ruby }} ruby-version: ${{ matrix.ruby }}
bundler-cache: true bundler-cache: true
- name: exec rake - name: Run tests
run: bundle exec rake
mri_build:
name: Ruby (${{ matrix.ruby }})
runs-on: ubuntu-latest
strategy:
matrix:
ruby: [2.6, 2.7, 3.0]
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
run: bundle exec rake run: bundle exec rake
+16 -5
View File
@@ -1,9 +1,11 @@
FROM ruby:2.7 FROM ruby:2.7-alpine AS builder
ENV DEBIAN_FRONTEND="noninteractive"
RUN apt-get update && apt-get install -y \ RUN apk add \
libicu-dev \ build-base \
cmake cmake \
git \
icu-dev \
openssl-dev
COPY Gemfile* /tmp/ COPY Gemfile* /tmp/
COPY gollum.gemspec* /tmp/ COPY gollum.gemspec* /tmp/
@@ -23,6 +25,15 @@ WORKDIR /app
COPY . /app COPY . /app
RUN bundle exec rake install RUN bundle exec rake install
FROM ruby:2.7-alpine
COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
RUN apk add \
bash \
git
VOLUME /wiki VOLUME /wiki
WORKDIR /wiki WORKDIR /wiki
COPY docker-run.sh /docker-run.sh COPY docker-run.sh /docker-run.sh
+21 -4
View File
@@ -1,9 +1,26 @@
source 'https://rubygems.org' source 'https://rubygems.org'
if RUBY_PLATFORM == 'java' gem 'warbler', platforms: :jruby
gem 'warbler'
end # FIXME:
#
# There's an issue in 1.12.5 that causes XHTML elements to be generated badly,
# causing Gollum's test suite to fail.[1] The issue has been fixed upstream,
# but we're still waiting for a new Nokogiri point release.
#
# However, 1.12.5 is a security patch, so we don't want end users to use an
# older version of Nokogiri. But this is safe to do in our CI environment.
#
# Once there's a new Nokogiri release, we can remove this dependency and JRuby
# CI should pass normally again.
#
# Note that Nokogiri 1.11+ does not support Ruby v2.4.x anymore. So to make our
# current CI workflows pass, we should only try to install this version of
# Nokogiri for newer Ruby versions.
#
# [1]: https://github.com/gollum/gollum/issues/1779
gem 'nokogiri', '1.12.4' unless RUBY_VERSION.include? '2.4'
gemspec gemspec
gem 'rake', '~> 13.0' gem 'rake', '~> 13.0'
+1 -1
View File
@@ -206,7 +206,7 @@ begin
rescue OptionParser::InvalidOption => e rescue OptionParser::InvalidOption => e
puts "gollum: #{e.message}" puts "gollum: #{e.message}"
puts 'gollum: try \'gollum --help\' for more information' puts 'gollum: try \'gollum --help\' for more information'
exit exit 1
end end
# --gollum-path wins over ARGV[0] # --gollum-path wins over ARGV[0]
+2 -1
View File
@@ -6,4 +6,5 @@ if [ ! -d .git ]; then
fi fi
# Start gollum service # Start gollum service
gollum --mathjax [[ "$@" != *--mathjax* ]] && echo "WARNING: Mathjax will soon be disabled by default. To explicitly enable it, use --mathjax" >&2
exec gollum $@ --mathjax
-1
View File
@@ -44,7 +44,6 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rack-test', '~> 0.6.3' s.add_development_dependency 'rack-test', '~> 0.6.3'
s.add_development_dependency 'shoulda', '~> 3.6.0' s.add_development_dependency 'shoulda', '~> 3.6.0'
s.add_development_dependency 'minitest-reporters', '~> 1.3.6' s.add_development_dependency 'minitest-reporters', '~> 1.3.6'
s.add_development_dependency 'twitter_cldr', '~> 3.2.0'
s.add_development_dependency 'mocha', '~> 1.8.0' s.add_development_dependency 'mocha', '~> 1.8.0'
s.add_development_dependency 'test-unit', '~> 3.3.0' s.add_development_dependency 'test-unit', '~> 3.3.0'
+3 -3
View File
@@ -20,6 +20,7 @@ require 'gollum/views/layout'
require 'gollum/views/editable' require 'gollum/views/editable'
require 'gollum/views/has_page' require 'gollum/views/has_page'
require 'gollum/views/has_user_icons' require 'gollum/views/has_user_icons'
require 'gollum/views/has_math'
require 'gollum/views/pagination' require 'gollum/views/pagination'
require 'gollum/views/rss.rb' require 'gollum/views/rss.rb'
require 'gollum/views/template_cascade' require 'gollum/views/template_cascade'
@@ -125,6 +126,7 @@ module Precious
@css = settings.wiki_options[:css] @css = settings.wiki_options[:css]
@js = settings.wiki_options[:js] @js = settings.wiki_options[:js]
@mathjax_config = settings.wiki_options[:mathjax_config] @mathjax_config = settings.wiki_options[:mathjax_config]
@mathjax = settings.wiki_options[:mathjax]
@use_static_assets = settings.wiki_options.fetch(:static, settings.environment != :development) @use_static_assets = settings.wiki_options.fetch(:static, settings.environment != :development)
@static_assets_path = settings.wiki_options.fetch(:static_assets_path, ::File.join(File.dirname(__FILE__), 'public/assets')) @static_assets_path = settings.wiki_options.fetch(:static_assets_path, ::File.join(File.dirname(__FILE__), 'public/assets'))
@@ -217,7 +219,6 @@ module Precious
if page = wikip.page if page = wikip.page
@page = page @page = page
@content = page.text_data @content = page.text_data
@mathjax = wiki.mathjax
@etag = page.sha @etag = page.sha
mustache :edit mustache :edit
else else
@@ -239,7 +240,7 @@ module Precious
halt 500 unless tempfile.is_a? Tempfile halt 500 unless tempfile.is_a? Tempfile
if wiki.per_page_uploads if wiki.per_page_uploads
dir = request.referer.sub(request.base_url, '') dir = request.referer.match(/^https?:\/\/#{request.host_with_port}\/(.*)/)[1]
# remove base path if it is set # remove base path if it is set
dir.sub!(/^#{wiki.base_path}/, '') if wiki.base_path dir.sub!(/^#{wiki.base_path}/, '') if wiki.base_path
# remove base_url and gollum/* subpath if necessary # remove base_url and gollum/* subpath if necessary
@@ -613,7 +614,6 @@ module Precious
# Extensions and layout data # Extensions and layout data
@editable = true @editable = true
@toc_content = wiki.universal_toc ? @page.toc_data : nil @toc_content = wiki.universal_toc ? @page.toc_data : nil
@mathjax = wiki.mathjax
@h1_title = wiki.h1_title @h1_title = wiki.h1_title
@bar_side = wiki.bar_side @bar_side = wiki.bar_side
@allow_uploads = wiki.allow_uploads @allow_uploads = wiki.allow_uploads
@@ -1 +1 @@
{"files":{"app-f05401ee374f0c7f48fc2bc08e30b4f4db705861fd5895ed70998683b383bfb5.js":{"logical_path":"app.js","mtime":"2021-07-10T00:40:20+09:00","size":136040,"digest":"f05401ee374f0c7f48fc2bc08e30b4f4db705861fd5895ed70998683b383bfb5","integrity":"sha256-8FQB7jdPDH9I/CvAjjC09NtwWGH9WJXtcJmGg7ODv7U="},"editor-9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a.js":{"logical_path":"editor.js","mtime":"2021-07-10T00:42:29+09:00","size":744886,"digest":"9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a","integrity":"sha256-mIHQx65mMpPw46fnJynux+lA+mExhcB2cJt20pL1cDo="},"app-cb122b4c17500faa5e013cb43334fafcf2dd7d72f694b06d9616f8b33fefb694.css":{"logical_path":"app.css","mtime":"2021-07-10T00:39:36+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-f05401ee374f0c7f48fc2bc08e30b4f4db705861fd5895ed70998683b383bfb5.js","editor.js":"editor-9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a.js","app.css":"app-cb122b4c17500faa5e013cb43334fafcf2dd7d72f694b06d9616f8b33fefb694.css","criticmarkup.css":"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css","print.css":"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css"}} {"files":{"app-f05401ee374f0c7f48fc2bc08e30b4f4db705861fd5895ed70998683b383bfb5.js":{"logical_path":"app.js","mtime":"2021-11-15T20:08:30-08:00","size":136040,"digest":"f05401ee374f0c7f48fc2bc08e30b4f4db705861fd5895ed70998683b383bfb5","integrity":"sha256-8FQB7jdPDH9I/CvAjjC09NtwWGH9WJXtcJmGg7ODv7U="},"editor-9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a.js":{"logical_path":"editor.js","mtime":"2021-11-15T20:08:30-08:00","size":744886,"digest":"9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a","integrity":"sha256-mIHQx65mMpPw46fnJynux+lA+mExhcB2cJt20pL1cDo="},"app-309be032396e783b13a47df58f389b7c8e11c2b2d42640560b874f677c25f6e5.css":{"logical_path":"app.css","mtime":"2021-11-15T20:08:30-08:00","size":396731,"digest":"309be032396e783b13a47df58f389b7c8e11c2b2d42640560b874f677c25f6e5","integrity":"sha256-MJvgMjlueDsTpH31jzibfI4RwrLUJkBWC4dPZ3wl9uU="},"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css":{"logical_path":"criticmarkup.css","mtime":"2021-08-22T15:24:51-07:00","size":646,"digest":"31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4","integrity":"sha256-Ma5dMoK7uOe3w8mRfp+2jjMVprSnXabOxI0huIRpBcQ="},"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css":{"logical_path":"print.css","mtime":"2021-08-22T15:24:51-07:00","size":75,"digest":"512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb","integrity":"sha256-USSYw2i+DT+xuhBd+oQomuSDgOyfy++Ui9TiOwsJW/s="}},"assets":{"app.js":"app-f05401ee374f0c7f48fc2bc08e30b4f4db705861fd5895ed70998683b383bfb5.js","editor.js":"editor-9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a.js","app.css":"app-309be032396e783b13a47df58f389b7c8e11c2b2d42640560b874f677c25f6e5.css","criticmarkup.css":"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css","print.css":"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css"}}
@@ -510,6 +510,14 @@ a {
border: none; border: none;
} }
#head .header-title {
font-size: 1.5em;
@include largemobile-breakpoint {
font-size: 32px;
}
}
/* Highlights */ /* Highlights */
.highlight { .highlight {
+3 -1
View File
@@ -1,6 +1,8 @@
<div id="wiki-wrapper" class="compare"> <div id="wiki-wrapper" class="compare">
<div id="head"> <div id="head">
<h1 class="py-4">{{message}}</h1> <h1 class="header-title text-center text-md-left py-4">
{{message}}
</h1>
{{author}} commited {{authored_date}} {{author}} commited {{authored_date}}
<span class="px-2 float-right">commit <code>{{version}}</code></span> <span class="px-2 float-right">commit <code>{{version}}</code></span>
</div> </div>
+10 -4
View File
@@ -1,8 +1,14 @@
<div id="wiki-wrapper" class="compare"> <div id="wiki-wrapper" class="compare">
<div id="head"> <div id="head">
{{>navbar}} {{>navbar}}
<h1 class="py-4"><span class="f1-light text-gray-light">Comparing versions of</span> {{name}}</h1>
</div> <h1 class="header-title text-center text-md-left py-4">
<span class="f1-light text-gray-light">
Comparing versions of
</span>
{{name}}
</h1>
</div>
{{#message}} {{#message}}
<p>{{message}}</p> <p>{{message}}</p>
+7 -4
View File
@@ -1,8 +1,11 @@
<div id="wiki-wrapper" class="create"> <div id="wiki-wrapper" class="create">
<div id="head"> <div id="head">
{{>navbar}} {{>navbar}}
<h1 class="py-4">Create New Page</h1>
</div> <h1 class="header-title text-center text-md-left py-4">
Create New Page
</h1>
</div>
<div id="wiki-content" class="create edit"> <div id="wiki-content" class="create edit">
<div class="tabnav"> <div class="tabnav">
<nav class="tabnav-tabs" aria-label="Toggle edit or preview mode"> <nav class="tabnav-tabs" aria-label="Toggle edit or preview mode">
+7 -4
View File
@@ -1,8 +1,11 @@
<div id="wiki-wrapper" class="edit"> <div id="wiki-wrapper" class="edit">
<div id="head"> <div id="head">
{{>navbar}} {{>navbar}}
<h1 class="py-4">Editing <strong>{{title}}</strong></h1>
</div> <h1 class="header-title text-center text-md-left py-4">
Editing <strong>{{title}}</strong>
</h1>
</div>
<div class="tabnav"> <div class="tabnav">
<nav class="tabnav-tabs"> <nav class="tabnav-tabs">
<a href="#" id="edit" class="tabnav-tab selected" aria-current="page"> <a href="#" id="edit" class="tabnav-tab selected" aria-current="page">
+9 -2
View File
@@ -1,8 +1,15 @@
<div id="wiki-wrapper" class="history"> <div id="wiki-wrapper" class="history">
<div id="head"> <div id="head">
{{>navbar}} {{>navbar}}
<h1 class="py-4"><span class="f1-light text-gray-light">History for</span> {{name}}</h1>
<h1 class="header-title text-center text-md-left py-4">
<span class="f1-light text-gray-light">
History for
</span>
{{name}}
</h1>
</div> </div>
<div id="page-history"> <div id="page-history">
{{>pagination}} {{>pagination}}
+7 -4
View File
@@ -1,8 +1,11 @@
<div id="wiki-wrapper" class="history"> <div id="wiki-wrapper" class="history">
<div id="head"> <div id="head">
{{>navbar}} {{>navbar}}
<h1 class="py-4">{{title}}</h1>
</div> <h1 class="header-title text-center text-md-left py-4">
{{title}}
</h1>
</div>
{{>pagination}} {{>pagination}}
+8 -1
View File
@@ -1,4 +1,11 @@
<nav class="TableObject actions pt-4 px-2 px-lg-0 overflow-x-scroll"> <nav class="TableObject
actions
border-bottom
border-md-0
p-2
pt-lg-4
px-lg-0
overflow-x-scroll">
<div class="TableObject-item hide-lg hide-xl"> <div class="TableObject-item hide-lg hide-xl">
{{>mobilenav}} {{>mobilenav}}
</div> </div>
+7 -4
View File
@@ -1,8 +1,11 @@
<div id="wiki-wrapper" class="results"> <div id="wiki-wrapper" class="results">
<div id="head" class="overview"> <div id="head" class="overview">
{{>navbar}} {{>navbar}}
<h1 class="py-4">{{title}}</h1>
</div> <h1 class="header-title text-center text-md-left py-4">
{{title}}
</h1>
</div>
<div id="overview"> <div id="overview">
{{#has_results}} {{#has_results}}
+7 -1
View File
@@ -1,7 +1,13 @@
<div id="wiki-wrapper" class="results"> <div id="wiki-wrapper" class="results">
<div id="head"> <div id="head">
{{>navbar}} {{>navbar}}
<h1 class="py-4"><span class="f1-light text-gray-light">Search results for</span> {{name}}</h1>
<h1 class="header-title text-center text-md-left py-4">
<span class="f1-light text-gray-light">
Search results for
</span>
{{name}}
</h1>
</div> </div>
{{#has_results}} {{#has_results}}
+3 -1
View File
@@ -1,5 +1,7 @@
<div id="wiki-content" class="px-2 px-lg-0"> <div id="wiki-content" class="px-2 px-lg-0">
<h1 class="pt-4">{{page_header}}</h1> <h1 class="header-title text-center text-md-left pt-4">
{{page_header}}
</h1>
<div class="breadcrumb">{{{breadcrumb}}}</div> <div class="breadcrumb">{{{breadcrumb}}}</div>
<div class="{{#has_header}}has-header{{/has_header}}{{#has_footer}} has-footer{{/has_footer}}{{#has_sidebar}} has-sidebar has-{{bar_side}}bar{{/has_sidebar}}{{#has_toc}} has-toc{{/has_toc}}"> <div class="{{#has_header}}has-header{{/has_header}}{{#has_footer}} has-footer{{/has_footer}}{{#has_sidebar}} has-sidebar has-{{bar_side}}bar{{/has_sidebar}}{{#has_toc}} has-toc{{/has_toc}}">
+3 -2
View File
@@ -2,6 +2,7 @@ module Precious
module Views module Views
class Create < Layout class Create < Layout
include Editable include Editable
include HasMath
attr_reader :page, :name attr_reader :page, :name
@@ -41,9 +42,9 @@ module Precious
def content def content
@template_page @template_page
end end
private private
def find_format def find_format
@found_format ||= (Gollum::Page.format_for("#{@name}#{@ext}") || default_markup) @found_format ||= (Gollum::Page.format_for("#{@name}#{@ext}") || default_markup)
end end
+2 -5
View File
@@ -3,6 +3,7 @@ module Precious
class Edit < Layout class Edit < Layout
include Editable include Editable
include HasPage include HasPage
include HasMath
attr_reader :page, :content attr_reader :page, :content
@@ -18,10 +19,6 @@ module Precious
def page_name def page_name
@name @name
end end
def mathjax
@mathjax
end
def header def header
if @header.nil? if @header.nil?
@@ -67,7 +64,7 @@ module Precious
def etag def etag
@etag @etag
end end
def allow_uploads def allow_uploads
@allow_uploads @allow_uploads
end end
+11
View File
@@ -0,0 +1,11 @@
module Precious
module HasMath
def mathjax
@mathjax
end
def mathjax_config
@mathjax_config
end
end
end
+8 -15
View File
@@ -2,9 +2,10 @@ module Precious
module Views module Views
class Page < Layout class Page < Layout
include HasPage include HasPage
include HasMath
attr_reader :content, :page, :header, :footer, :preview, :historical attr_reader :content, :page, :header, :footer, :preview, :historical
VALID_COUNTER_STYLES = ['decimal', 'decimal-leading-zero', 'arabic-indic', 'armenian', 'upper-armenian', VALID_COUNTER_STYLES = ['decimal', 'decimal-leading-zero', 'arabic-indic', 'armenian', 'upper-armenian',
'lower-armenian', 'bengali', 'cambodian', 'khmer', 'cjk-decimal', 'devanagari', 'georgian', 'gujarati', 'gurmukhi', 'lower-armenian', 'bengali', 'cambodian', 'khmer', 'cjk-decimal', 'devanagari', 'georgian', 'gujarati', 'gurmukhi',
'hebrew', 'kannada', 'lao', 'malayalam', 'mongolian', 'myanmar', 'oriya', 'persian', 'lower-roman', 'upper-roman', 'hebrew', 'kannada', 'lao', 'malayalam', 'mongolian', 'myanmar', 'oriya', 'persian', 'lower-roman', 'upper-roman',
@@ -61,11 +62,11 @@ module Precious
def editable def editable
@editable @editable
end end
def search def search
true true
end end
def history def history
true true
end end
@@ -73,11 +74,11 @@ module Precious
def latest_changes def latest_changes
true true
end end
def overview def overview
true true
end end
def allow_editing def allow_editing
@allow_editing @allow_editing
end end
@@ -157,14 +158,6 @@ module Precious
@toc_content @toc_content
end end
def mathjax
@mathjax
end
def mathjax_config
@mathjax_config
end
def use_identicon def use_identicon
@page.wiki.user_icons == 'identicon' @page.wiki.user_icons == 'identicon'
end end
@@ -182,7 +175,7 @@ module Precious
# Returns Hash. # Returns Hash.
def metadata def metadata
@page.metadata @page.metadata
end end
# Access to embedded metadata. # Access to embedded metadata.
# #
-1
View File
@@ -6,7 +6,6 @@ require 'mocha/setup'
require 'fileutils' require 'fileutils'
require 'minitest/reporters' require 'minitest/reporters'
require 'minitest/spec' require 'minitest/spec'
require 'twitter_cldr'
require 'tmpdir' require 'tmpdir'
# Silence locale validation warning # Silence locale validation warning
+30 -17
View File
@@ -39,31 +39,29 @@ context "Frontend" do
assert_match /<pre><code>one\ntwo\nthree\nfour\n<\/code><\/pre>\n/m, last_response.body assert_match /<pre><code>one\ntwo\nthree\nfour\n<\/code><\/pre>\n/m, last_response.body
end end
def nfd utf8
TwitterCldr::Normalization.normalize(utf8, using: :nfd)
end
test 'mathjax assets are served' do test 'mathjax assets are served' do
get '/gollum/assets/mathjax/MathJax.js' get '/gollum/assets/mathjax/MathJax.js'
assert last_response.ok? assert last_response.ok?
end end
test "UTF-8 headers href preserved" do test "UTF-8 headers href preserved" do
page = 'utfh1' page_content = <<~TEXT
text = nfd('한글') ## 한글
# don't use h1 or it will be promoted to replace file name Test page "utfh1" content.
# which doesn't generate a normal header link TEXT
@wiki.write_page(page, :markdown, '## ' + text,
{ :name => 'user1', :email => 'user1' });
get page @wiki.write_page('utfh1',
expected = "<h2 class=\"editable\"><a class=\"anchor\" (href|id)=\"(#)?#{text}\" (href|id)=\"(#)?#{text}\"></a>#{text}</h2>" :markdown,
actual = nfd(last_response.body) page_content,
{name: 'user1', email: 'user1'})
assert_match /#{expected}/, actual get 'utfh1'
expected = "<h2 class=\"editable\"><a class=\"anchor\" (href|id)=\"(#)?한글\" (href|id)=\"(#)?한글\"></a>한글</h2>"
assert_match /#{expected}/, last_response.body
end end
test 'rss feed' do test 'rss feed' do
channel_title = <<EOF channel_title = <<EOF
<title>Gollum Wiki Latest Changes</title> <title>Gollum Wiki Latest Changes</title>
@@ -447,6 +445,21 @@ EOF
Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false}) Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false})
end end
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
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 "guard against uploading an existing file" do test "guard against uploading an existing file" do
temp_upload_file = Tempfile.new(['upload', '.file']) << 'abc' temp_upload_file = Tempfile.new(['upload', '.file']) << 'abc'
temp_upload_file.close temp_upload_file.close
@@ -476,9 +489,9 @@ EOF
test "previews content" do test "previews content" do
post "/gollum/preview", :content => 'abc', :format => 'markdown', :page => 'Samewise Gamgee.mediawiki' post "/gollum/preview", :content => 'abc', :format => 'markdown', :page => 'Samewise Gamgee.mediawiki'
assert last_response.ok? assert last_response.ok?
assert last_response.body.include?('Samewise Gamgee</h1>') assert last_response.body.include?('Samewise Gamgee')
end end
test 'throws an error when comparing two identical revisions for a page' do test 'throws an error when comparing two identical revisions for a page' do
get '/gollum/compare/A.md/fc66539528eb96f21b2bbdbf557788fe8a1196ac...fc66539528eb96f21b2bbdbf557788fe8a1196ac' get '/gollum/compare/A.md/fc66539528eb96f21b2bbdbf557788fe8a1196ac...fc66539528eb96f21b2bbdbf557788fe8a1196ac'
assert last_response.ok? assert last_response.ok?