Compare commits

...

42 Commits

Author SHA1 Message Date
Bart Kamphorst 906dab700f Normalize the page contents used to create a PreviewPage. Fixes #1617. 2020-09-20 18:32:15 +02:00
Bart Kamphorst c5894dd4df Filter _Template content. Proposed solution to #1603. 2020-08-25 16:55:00 +02:00
Dawa Ometto 986a76cf8e Release 5.1.1 2020-08-11 12:57:42 +02:00
Dawa Ometto 42439033c8 Release 5.1 2020-08-03 19:07:32 +02:00
Dawa Ometto 421ff18788 Updating assets for bugfix release. 2020-08-03 19:01:29 +02:00
Dawa Ometto 519a275ff0 Fix mathjax config path (#1605)
Related to #1602
2020-08-03 19:00:49 +02:00
Watal M. Iwasaki 5a95f79b32 Ensure page_route starts with a leading slash (#1604)
* Ensure page_route starts with a leading slash

* Handle base_url = nil in page_route()

* Refactor page_route()
2020-08-03 18:09:57 +02:00
Dawa Ometto 627ee5bbbe Merge pull request #1595 from heavywatal/upload-whitespaced-file
Address the uploads issue. Resolves #1584
2020-08-03 18:05:27 +02:00
Dawa Ometto a9d300341c Merge pull request #1594 from heavywatal/empty-search
Show search page even when no parameters are given
2020-07-15 12:46:18 +02:00
Dawa Ometto 6b7e912010 Merge pull request #1593 from heavywatal/fix-home-button
Address home button issue #1590
2020-07-15 12:44:13 +02:00
Watal M. Iwasaki 4feae80814 Update assets 2020-07-12 17:39:18 +09:00
Watal M. Iwasaki 5f5730fe2e Address the uploads issue #1584
'%20' in filenames are translated back to ' ' in both editor and file creation.
2020-07-12 17:37:20 +09:00
Watal M. Iwasaki 5f784f5e10 Show search page even when no parameters are given
This PR addresses the issue #1586
2020-07-12 15:22:18 +09:00
Watal M. Iwasaki 35a44efafd Address home button issue #1590
A trailing slash is added.
This fixes the behavior when base_url is nil.
2020-07-12 13:41:41 +09:00
Dawa Ometto b32dcfa8dd Merge pull request #1580 from heavywatal/reduce-direct-base_url
Reduce direct use of base_url
2020-06-17 10:37:15 +02:00
Watal M. Iwasaki 38fc32bbdd Return nil if url.empty? right after url.comact! 2020-06-16 17:55:01 +09:00
Watal M. Iwasaki 6c7b12ae5e Restore base_url for baseUrl in JavaScript 2020-06-16 17:29:32 +09:00
Dawa Ometto 649e19bdb1 Merge pull request #1578 from tpoliaw/no-edit-compare
Let compare versions be used in no-edit mode
2020-06-15 12:13:34 +02:00
Watal M. Iwasaki a4266170ea Address the issue #1572 (#1581)
* Add double-quote to data-file-path={{url}}
2020-06-15 12:02:32 +02:00
Watal M. Iwasaki 6e6d9d8c1f Use page_route() for custom.css, custom.js, and MathJax 2020-06-14 23:11:07 +09:00
Watal M. Iwasaki e49758334f Replace base_url with page_route() 2020-06-14 23:11:07 +09:00
Watal M. Iwasaki 580068212d Remove base_url from search.mustache 2020-06-14 23:11:07 +09:00
Watal M. Iwasaki 504278d9ba Move full_url_path from HasPage to Page
so that page_route() is accessible via Layout
2020-06-14 23:11:07 +09:00
Watal M. Iwasaki 214056a88a Refactor regex in clean_url() 2020-06-14 23:11:07 +09:00
Watal M. Iwasaki e310f76030 Enhance RouteHelpers
- page_route() accepts nil and return base_url
- clean_url() accepts multiple args and join them
2020-06-14 23:11:07 +09:00
Peter Holloway 83abe62125 Use GET for compare methods
POST requests are blocked when running in --no-edit mode so using POST
prevents compare being available (see #1546).

Change the history view form to use "get" as the form method and change
the routing in app to accept get requests for both forms of compare. The
order of the compare routes is switched to make the more specific form
checked first to prevent all requests being handled by the less specific
form.
2020-06-10 23:27:48 +01:00
Bart Kamphorst 8e7a714991 Merge pull request #1577 from gollum/fix_1571
Remove superfluous closing div tag. Add ids to all navigation buttons.
2020-06-09 09:30:27 +02:00
Bart Kamphorst 4f67710ed2 Remove superfluous closing div tag. Add ids to all navigation buttons. 2020-06-08 22:09:04 +02:00
Bart Kamphorst 8ec8be5db3 Merge pull request #1576 from mivok/feature/auto_save
Add auto save functionality
2020-06-08 21:26:54 +02:00
Watal M. Iwasaki 92da563211 Add quick access to diff of each commit in the history (#1555) 2020-06-08 20:49:34 +02:00
Mark Harrison 2eb5a7e4b8 Remove flash-full from the notification class list
It doesn't look right with the banner in the new position.
2020-06-05 22:59:20 -04:00
Mark Harrison 23110d5f05 Add autosave/restore for subpages too 2020-06-05 22:51:14 -04:00
Mark Harrison 18de3272e3 Move autosave message elements into the template 2020-06-05 21:34:07 -04:00
Mark Harrison 1e81c42818 Add auto save functionality
Fixes #527

This adds auto saving to gollum using local storage.
2020-06-04 22:30:40 -04:00
Dawa Ometto ef6e0e8a07 Fix gollum link tag highlighting (#1566) 2020-05-15 10:29:38 +02:00
Watal M. Iwasaki ba575b886d Simulate 'git show' when a single version is posted from /history/ (#1543) 2020-04-16 12:50:45 +02:00
Dawa Ometto c8f856109d Set environment to production when precompiling (#1554) 2020-04-14 11:50:29 +02:00
Sven Schwyn 4035c579c7 Don't uglify JS in development env (#1551) 2020-04-14 11:22:48 +02:00
Bart Kamphorst 8bab3de510 Merge pull request #1549 from yuttie/yuttie-patch-fix-data-file-path
Fix `data-file-path` in overview pages
2020-04-10 13:02:13 +02:00
Yuta Taniguchi 9ab4bbb17c Fix data-file-path
This correct the `data-file-path` attribute's value so that the value includes the ancestor directories to a file.
2020-04-09 23:51:02 +09:00
Bart Kamphorst ae024eb3b3 Merge pull request #1547 from heavywatal/flash-notice-h1
Fix a selector in flashNotice()
2020-04-08 20:16:04 +02:00
Watal M. Iwasaki db84653bf2 Fix a selector in flashNotice()
The original selector "#wiki-content h1" matches multiple times
when the page content has h1 headers, resulting in multiple notice
in a page, and what is worse, "$('#gollum-flash').fadeOut()" works
only for the first one.
2020-04-08 22:45:49 +09:00
37 changed files with 303 additions and 96 deletions
+6
View File
@@ -1,3 +1,9 @@
# 5.1
* Bugfixes
* Add autosave feature (#1576)
* Add Add quick access to diff of each commit in the history
# 5.0 / 2020-03-17
This is a major new release that introduces many new features, bugfixes, and removes major limitations. See [here](https://github.com/gollum/gollum/wiki/5.0-release-notes) for a list of changes.
+2
View File
@@ -5,6 +5,8 @@ gollum -- A git-based Wiki
[![Build Status](https://travis-ci.org/gollum/gollum.svg?branch=master)](https://travis-ci.org/gollum/gollum)
[![Open Source Helpers](https://www.codetriage.com/gollum/gollum/badges/users.svg)](https://www.codetriage.com/gollum/gollum)
**Please update to gollum 5.1.1 to counter a recent exploit in the kramdown rendering gem, [CVE-2020-14001](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-14001)**
**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
+2 -5
View File
@@ -181,11 +181,8 @@ end
desc 'Precompile assets'
task :precompile do
require './lib/gollum/views/helpers.rb'
require './lib/gollum/assets.rb'
require 'sprockets'
require 'sprockets-helpers'
require 'sass'
require './lib/gollum/app.rb'
Precious::App.set(:environment, :production)
env = Precious::Assets.sprockets
path = ENV.fetch('GOLLUM_ASSETS_PATH', ::File.join(File.dirname(__FILE__), 'lib/gollum/public/assets'))
manifest = Sprockets::Manifest.new(env, path)
+10 -8
View File
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 1.9'
s.name = 'gollum'
s.version = '5.0.1'
s.date = '2020-04-04'
s.version = '5.1.1'
s.date = '2020-08-11'
s.license = 'MIT'
s.summary = 'A simple, Git-powered wiki.'
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.extra_rdoc_files = %w[README.md LICENSE]
s.add_dependency 'gollum-lib', '~> 5.0'
s.add_dependency 'kramdown', '~> 2.1.0'
s.add_dependency 'kramdown', '~> 2.3'
s.add_dependency 'kramdown-parser-gfm', '~> 1.0.0'
s.add_dependency 'sinatra', '~> 2.0'
s.add_dependency 'sinatra-contrib', '~> 2.0'
@@ -68,15 +68,15 @@ Gem::Specification.new do |s|
lib/gollum/app.rb
lib/gollum/assets.rb
lib/gollum/helpers.rb
lib/gollum/public/assets/.sprockets-manifest-3edc7e21737459b21fbf150f5dccd15c.json
lib/gollum/public/assets/app-982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5.js
lib/gollum/public/assets/app-982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5.js.gz
lib/gollum/public/assets/.sprockets-manifest-459226ba5fc211b78ba9a3aa6ebde96c.json
lib/gollum/public/assets/app-6e925e38a12a40c4fa9e0400cc874e0f4f97b66fdeb90a144dea527dbb544fbd.js
lib/gollum/public/assets/app-6e925e38a12a40c4fa9e0400cc874e0f4f97b66fdeb90a144dea527dbb544fbd.js.gz
lib/gollum/public/assets/app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css
lib/gollum/public/assets/app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css.gz
lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css
lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css.gz
lib/gollum/public/assets/editor-0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1.js
lib/gollum/public/assets/editor-0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1.js.gz
lib/gollum/public/assets/editor-b2c10f22ef6ca1e120956a2d11ff4ca19ac44d7e7240f5cc43ec949184d8b708.js
lib/gollum/public/assets/editor-b2c10f22ef6ca1e120956a2d11ff4ca19ac44d7e7240f5cc43ec949184d8b708.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
@@ -1190,6 +1190,7 @@ Gem::Specification.new do |s|
lib/gollum/public/gollum/stylesheets/spinner.scss
lib/gollum/public/gollum/stylesheets/tables.scss
lib/gollum/public/gollum/stylesheets/template.scss.erb
lib/gollum/templates/commit.mustache
lib/gollum/templates/compare.mustache
lib/gollum/templates/create.mustache
lib/gollum/templates/edit.mustache
@@ -1209,6 +1210,7 @@ Gem::Specification.new do |s|
lib/gollum/templates/searchbar.mustache
lib/gollum/templates/wiki_content.mustache
lib/gollum/uri_encode_component.rb
lib/gollum/views/commit.rb
lib/gollum/views/compare.rb
lib/gollum/views/create.rb
lib/gollum/views/edit.rb
+1 -1
View File
@@ -12,7 +12,7 @@ require 'rhino' if RUBY_PLATFORM == 'java'
require File.expand_path('../gollum/uri_encode_component', __FILE__)
module Gollum
VERSION = '5.0.1'
VERSION = '5.1.1'
def self.assets_path
::File.expand_path('gollum/public', ::File.dirname(__FILE__))
+55 -22
View File
@@ -230,14 +230,15 @@ module Precious
halt 500 unless tempfile.is_a? Tempfile
if wiki.per_page_uploads
# remove base_url and gollum/* subpath if necessary
dir = request.referer.
sub(request.base_url, '').
sub(/.*gollum\/[-\w]+\//, '')
dir = request.referer.sub(request.base_url, '')
# remove base path if it is set
dir = 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
dir.sub!(/^\/gollum\/[-\w]+\//, '')
# remove file extension
dir = dir.sub(::File.extname(dir), '')
dir.sub!(/#{::File.extname(dir)}$/, '')
# revert escaped whitespaces
dir.gsub!(/%20/, ' ')
dir = ::File.join('uploads', dir)
else
# store all uploads together
@@ -354,6 +355,9 @@ module Precious
if settings.wiki_options[:template_page] then
temppage = wiki_page('/_Template')
@template_page = (temppage.page != nil) ? temppage.page.raw_data : 'Template page option is set, but no /_Template page is present or committed.'
if defined?(Gollum::TemplateFilter)
@template_page = Gollum::TemplateFilter.filter(@template_page)
end
end
wikip = wiki_page(params[:splat].first)
@name = wikip.name
@@ -417,7 +421,7 @@ module Precious
post '/preview' do
wiki = wiki_new
@name = params[:page] ? strip_page_name(CGI.unescape(params[:page])) : 'Preview'
@page = wiki.preview_page(@name, params[:content], params[:format])
@page = wiki.preview_page(@name, wiki.normalize(params[:content]), params[:format])
['sidebar', 'header', 'footer'].each do |subpage|
@page.send("set_#{subpage}".to_sym, params[subpage]) if params[subpage]
end
@@ -459,20 +463,6 @@ module Precious
mustache :latest_changes
end
post '/compare/*' do
@file = clean_url(encodeURIComponent(params[:splat].first))
@versions = params[:versions] || []
if @versions.size < 2
redirect to("gollum/history/#{@file}")
else
redirect to("gollum/compare/%s/%s...%s" % [
@file,
@versions.last,
@versions.first]
)
end
end
get %r{
/compare/ # match any URL beginning with /compare/
(.+) # extract the full path (including any directories)
@@ -496,8 +486,51 @@ module Precious
end
end
get '/compare/*' do
@file = clean_url(encodeURIComponent(params[:splat].first))
@versions = params[:versions] || []
if @versions.size == 1
wikip = wiki_page(params[:splat].first)
commit = wikip.wiki.repo.commit(@versions.first)
parent = commit.parent
if parent.nil?
redirect to("#{@file}/#{@commit.id}")
else
@versions.push(parent.id)
end
end
if @versions.empty?
redirect to("gollum/history/#{@file}")
else
redirect to("gollum/compare/%s/%s...%s" % [
@file,
@versions.last,
@versions.first]
)
end
end
get %r{
/commit/ # match any URL beginning with /show/
(\w+) # match the SHA1
}x do |version|
@version = version
wiki = wiki_new
begin
@commit = wiki.repo.commit(version)
parent = @commit.parent
parent_id = parent.nil? ? nil : parent.id
@diff = wiki.repo.diff(parent_id, version)
mustache :commit
rescue Gollum::Git::NoSuchShaFound
@message = "Invalid commit: #{@version}"
mustache :error
end
end
get '/search' do
@query = params[:q]
@query = params[:q] || ''
@name = @query
if @query.empty?
@results = []
+3 -3
View File
@@ -4,7 +4,7 @@ module Precious
module Assets
MANIFEST = %w(app.js editor.js app.css criticmarkup.css fileview.css ie7.css print.css *.png *.jpg *.svg *.eot *.ttf)
ASSET_URL = 'gollum/assets'
def self.sprockets(dir = File.dirname(File.expand_path(__FILE__)))
env = Sprockets::Environment.new
env.append_path ::File.join(dir, 'public/gollum/stylesheets/')
@@ -12,7 +12,7 @@ module Precious
env.append_path ::File.join(dir, 'public/gollum/images')
env.append_path ::File.join(dir, 'public/gollum/fonts')
env.js_compressor = :uglify
env.js_compressor = :uglify unless Precious::App.development?
env.css_compressor = :scss
env.context_class.class_eval do
@@ -26,4 +26,4 @@ module Precious
env
end
end
end
end
+1 -1
View File
@@ -19,7 +19,7 @@ module Precious
# Remove all double slashes
def clean_url(url)
return url if url.nil?
url.gsub('%2F', '/').gsub(/^\/+/, '').gsub('//', '/')
url.gsub('%2F', '/').gsub(%r{/{2,}}, '/').gsub(%r{^/}, '')
end
def forbid(msg = "Forbidden. This wiki is set to no-edit mode.")
@@ -1 +1 @@
{"files":{"app-982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5.js":{"logical_path":"app.js","mtime":"2020-03-30T11:12:22+02:00","size":136039,"digest":"982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5","integrity":"sha256-mCx/yhgycyok6SR0yicprrVvLQwFu3qP+RPp9YplANU="},"editor-0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1.js":{"logical_path":"editor.js","mtime":"2020-03-29T22:28:50+02:00","size":746117,"digest":"0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1","integrity":"sha256-DbrijFPbWnPWZtMFBJRmcesJlI/9rx/dnRyNhW1MC6E="},"app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css":{"logical_path":"app.css","mtime":"2020-03-30T11:12:22+02:00","size":298111,"digest":"b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7","integrity":"sha256-sgXlk6MPHMAFTi6e2fyK82WNjvSmK5cIwg8gRWDe77c="},"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css":{"logical_path":"criticmarkup.css","mtime":"2020-03-29T22:28:51+02:00","size":646,"digest":"31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4","integrity":"sha256-Ma5dMoK7uOe3w8mRfp+2jjMVprSnXabOxI0huIRpBcQ="},"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css":{"logical_path":"print.css","mtime":"2020-03-30T11:12:22+02:00","size":75,"digest":"512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb","integrity":"sha256-USSYw2i+DT+xuhBd+oQomuSDgOyfy++Ui9TiOwsJW/s="}},"assets":{"app.js":"app-982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5.js","editor.js":"editor-0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1.js","app.css":"app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css","criticmarkup.css":"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css","print.css":"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css"}}
{"files":{"app-6e925e38a12a40c4fa9e0400cc874e0f4f97b66fdeb90a144dea527dbb544fbd.js":{"logical_path":"app.js","mtime":"2020-08-03T18:13:54+02:00","size":136032,"digest":"6e925e38a12a40c4fa9e0400cc874e0f4f97b66fdeb90a144dea527dbb544fbd","integrity":"sha256-bpJeOKEqQMT6ngQAzIdOD0+Xtm/euQoUTepSfbtUT70="},"editor-b2c10f22ef6ca1e120956a2d11ff4ca19ac44d7e7240f5cc43ec949184d8b708.js":{"logical_path":"editor.js","mtime":"2020-08-03T18:13:54+02:00","size":747273,"digest":"b2c10f22ef6ca1e120956a2d11ff4ca19ac44d7e7240f5cc43ec949184d8b708","integrity":"sha256-ssEPIu9soeEglWotEf9MoZrETX5yQPXMQ+yUkYTYtwg="},"app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css":{"logical_path":"app.css","mtime":"2020-03-30T11:12:22+02:00","size":298111,"digest":"b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7","integrity":"sha256-sgXlk6MPHMAFTi6e2fyK82WNjvSmK5cIwg8gRWDe77c="},"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css":{"logical_path":"criticmarkup.css","mtime":"2020-03-29T22:28:51+02:00","size":646,"digest":"31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4","integrity":"sha256-Ma5dMoK7uOe3w8mRfp+2jjMVprSnXabOxI0huIRpBcQ="},"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css":{"logical_path":"print.css","mtime":"2020-03-30T11:12:22+02:00","size":75,"digest":"512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb","integrity":"sha256-USSYw2i+DT+xuhBd+oQomuSDgOyfy++Ui9TiOwsJW/s="}},"assets":{"app.js":"app-6e925e38a12a40c4fa9e0400cc874e0f4f97b66fdeb90a144dea527dbb544fbd.js","editor.js":"editor-b2c10f22ef6ca1e120956a2d11ff4ca19ac44d7e7240f5cc43ec949184d8b708.js","app.css":"app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css","criticmarkup.css":"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css","print.css":"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css"}}
@@ -17,6 +17,8 @@
NoDefinitionsFor: []
};
var ActiveOptions = {};
var autoSaveTimer = null;
var storageKey = 'gollum_autorecover_' + window.location;
function isRTL(s){
var ltrChars = 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF'+'\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF',
@@ -32,6 +34,27 @@
window.ace_editor.renderer.updateFull();
}
function autoSaveHandler() {
// Autosave
if (autoSaveTimer) {
// Reset the timer because we just changed the text
clearTimeout(autoSaveTimer);
}
$('#gollum-saved-msg').text('Saving...');
// Wait 2 seconds, then actualy save the text to local storage
autoSaveTimer = setTimeout(function() {
localStorage.setItem(storageKey, window.ace_editor.getSession().getValue());
// Save any subpage editor text that might exist
$('#gollum-editor-header, #gollum-editor-footer, #gollum-editor-sidebar').each(function(_, el) {
var spStorageKey = storageKey + el.id.replace('gollum-editor-', '_');
localStorage.setItem(spStorageKey, el.value);
});
$('#gollum-saved-msg').text('Saved recovery text');
}, 2000);
}
/**
* $.GollumEditor
*
@@ -55,6 +78,26 @@
var editor = ace.edit(editDiv[0], {rtlText: true});
window.ace_editor = editor;
// Check to see if we have any autosaved text and show a message to
// restore it if present.
var savedText = localStorage.getItem(storageKey);
if (savedText) {
$('#gollum-autorecover-button').click(function(e) {
editor.getSession().setValue(savedText);
// Restore subpage editor values too, if they exist
['header', 'footer', 'sidebar'].forEach(function(i) {
var sbSavedText = localStorage.getItem(storageKey + '_' + i);
if (sbSavedText) {
$('#gollum-editor-' + i).val(sbSavedText);
}
});
$('#gollum-autorecover-msg')[0].hidden = true;
e.preventDefault();
});
$('#gollum-autorecover-msg')[0].hidden = false;
}
editor.setTheme("ace/theme/tomorrow");
editor.setKeyboardHandler();
editor.renderer.setShowGutter(false);
@@ -64,8 +107,13 @@
editor.getSession().on('change', function(){
textarea.val(editor.getSession().getValue());
autoSaveHandler();
});
// Autosave for the header, footer and sidebar
$('#gollum-editor-header, #gollum-editor-footer, #gollum-editor-sidebar')
.on('change keyup paste', autoSaveHandler);
if (isRTL(editor.getSession().getLine(0))) {
switchRtl(true);
}
@@ -114,6 +162,16 @@
editor.focus();
});
// Remove any autosaved text when we hit save or cancel
$("#gollum-editor-submit, #gollum-editor-cancel").click(function() {
var storageKey = 'gollum_autorecover_' + window.location;
localStorage.removeItem(storageKey);
// Clear subpage editor values too, if they exist
['header', 'footer', 'sidebar'].forEach(function(i) {
localStorage.removeItem(storageKey + '_' + i);
});
});
debug('GollumEditor loading');
if ( EditorHas.baseEditorMarkup() ) {
@@ -241,6 +299,7 @@
var ext = file.name.split('.').pop().toLowerCase()
var image_ext = ['jpg', 'jpeg', 'tif', 'tiff', 'png', 'gif', 'svg', 'bmp']
// Link directly to image files
uploadDest = uploadDest.replace(/%20/g, ' ');
if ((image_ext.indexOf(ext) > -1)) {
var text = '[[/' + uploadDest + '/' + file.name + ']]';
} else {
@@ -23,7 +23,7 @@
// For Gollum link tags
var GollumTagStart = {
token: "support.function",
regex: "\\[\\[.*\\]\\]",
regex: "\\[\\[[^\\]]*\\]\\]",
next: 'start'
};
@@ -105,7 +105,7 @@ function flashNotice(type, notice, button_label, button_function, button_type) {
}
html = '<p><div id="gollum-flash" class="flash flash-' + type +'"><button class="flash-close js-flash-close" type="button" onclick="parentNode.remove()"><%=rocticon('x')%></button>' + notice + nested_button_html + '</div></p>';
$('#gollum-flash').remove();
$('#wiki-content h1').before(html);
$('#wiki-content').before(html);
if (type == 'success') { setTimeout(function() {$('#gollum-flash').fadeOut();}, 5000); }
}
@@ -345,7 +345,8 @@ $(document).ready(function() {
var formData = new FormData($('#gollum-editor-form').get(0));
var paths = window.location.pathname.split('/');
var sectionAnchor = window.location.hash.substr(1);
formData.append('page', paths[ paths.length - 1 ] || '')
formData.append('page', paths[ paths.length - 1 ] || '');
$.ajax({
url: routePath('preview'),
data: formData,
@@ -486,12 +487,13 @@ $(document).ready(function() {
}
numSelected = numSelected + 1;
});
if (numSelected == maxSelected) {
$('#version-form input:not(:checked)').prop('disabled', true);
$('.history button.action-compare-revision').prop('disabled', false);
} else if (numSelected < maxSelected) {
$('#version-form input').prop('disabled', false);
if (numSelected < 1) {
$('.history button.action-compare-revision').prop('disabled', true);
} else if (numSelected < maxSelected) {
$('.history button.action-compare-revision').prop('disabled', false);
$('#version-form input').prop('disabled', false);
} else {
$('#version-form input:not(:checked)').prop('disabled', true);
}
};
+26
View File
@@ -0,0 +1,26 @@
<div id="wiki-wrapper" class="compare">
<div id="head">
<h1 class="py-4">{{message}}</h1>
{{author}} commited {{authored_date}}
<span class="px-2 float-right">commit <code>{{version}}</code></span>
</div>
<div id="compare-content">
{{#files}}
<div class="Box data highlight my-3">
<div class="Box-header Box--condensed Box-header--gray">
<code>{{path}}</code>
</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>
{{/files}}
</div>
</div>
+5
View File
@@ -96,6 +96,10 @@
</p>
</div>
</div>
</div>
<div id="gollum-autorecover-msg" class="flash" hidden>
Autosaved text is available. Click the button to restore it.
<button id="gollum-autorecover-button" class="btn btn-sm primary flash-action">Restore Text</button>
</div>
<textarea id="gollum-editor-body" class="form-control"
data-markup-lang="{{format}}" name="content" class="mousetrap">{{content}}</textarea>
@@ -147,3 +151,4 @@
</fieldset>
</form>
</div>
<div id="gollum-saved-msg" class="position-fixed bottom-0 left-0"></div>
+5 -2
View File
@@ -7,7 +7,7 @@
{{>pagination}}
<form name="selection-form" id="selection-form" method="post" 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">
@@ -18,7 +18,10 @@
<span class="float-left col-2" id="user-icons">{{>author_template}}</span>
<span class="flex-auto col-1 text-gray-light">{{date}}</span>
<span class="flex-auto col-5">{{message}}</span>
<span class="pl-4 float-right">[<a href="{{base_url}}/{{filename}}/{{id}}" title="View commit">{{id7}}</a>]</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>
+7 -5
View File
@@ -8,9 +8,9 @@
<div id="wiki-history">
<div class="Box flex-auto">
<ul class="Box flex-auto">
{{#versions}}
<div class="Box-row Box-row--hover-gray border-top d-flex flex-items-center">
<li class="Box-row Box-row--hover-gray border-top d-flex flex-items-center">
<span class="float-left col-2" id="user-icons">{{>author_template}}</span>
<span class="flex-auto col-1 text-gray-light">{{date}}</span>
<span class="flex-auto col-7">{{message}}<br/>
@@ -18,10 +18,12 @@
<span class="flex-auto col-2">{{#renamed}}{{renamed}} -> {{/renamed}}<a href="{{link}}">{{file}}</a></span><br/>
{{/files}}
</span>
<span class="pl-4 float-right">[{{id7}}]</span>
</div>
<span class="pl-4 float-right">
<a href="{{href}}" class="btn btn-outline text-mono">{{id7}}</a>
</span>
</li>
{{/versions}}
</div>
</ul>
</div>
+4 -4
View File
@@ -8,7 +8,7 @@
{{#sprockets_stylesheet_tag}}app{{/sprockets_stylesheet_tag}}
{{#sprockets_stylesheet_tag}}print print{{/sprockets_stylesheet_tag}}
{{#css}}<link rel="stylesheet" type="text/css" href="{{custom_path}}/custom.css" media="all">{{/css}}
{{#css}}<link rel="stylesheet" type="text/css" href="{{custom_css}}" media="all">{{/css}}
{{#noindex}}<meta name="robots" content="noindex, nofollow" />{{/noindex}}
@@ -49,11 +49,11 @@
};
</script>
{{#mathjax_config}}
<script type="text/javascript" src="{{base_url}}/{{mathjax_config}}"></script>
<script type="text/javascript" src="{{mathjax_config_path}}"></script>
{{/mathjax_config}}
<script defer src="{{base_url}}/gollum/assets/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script defer src="{{mathjax_js}}"></script>
{{/mathjax}}
{{#js}}<script type="text/javascript" src="{{custom_path}}/custom.js"></script>{{/js}}
{{#js}}<script type="text/javascript" src="{{custom_js}}"></script>{{/js}}
<title>{{title}}</title>
</head>
+4 -4
View File
@@ -2,7 +2,7 @@
<div class="TableObject">
<div class="TableObject-item">
<a class="btn" href="{{base_url}}/">Home</a>
<a class="btn" id="minibutton-home" href="{{page_route}}">Home</a>
</div>
@@ -11,13 +11,13 @@
</div>
<div class="TableObject-item">
{{#overview}}<a class="btn" href="{{overview_path}}">Overview</a>{{/overview}}
{{#latest_changes}}<a class="btn" href="{{latest_changes_path}}">Latest Changes</a>{{/latest_changes}}
{{#overview}}<a class="btn" id="minibutton-overview" href="{{overview_path}}">Overview</a>{{/overview}}
{{#latest_changes}}<a class="btn" id="minibutton-latest-changes" href="{{latest_changes_path}}">Latest Changes</a>{{/latest_changes}}
</div>
{{#history}}
<div class="TableObject-item pl-1">
<a class="btn" href="{{history_path}}/{{escaped_url_path}}">Page History</a>
<a class="btn" id="minibutton-history" href="{{history_path}}/{{escaped_url_path}}">Page History</a>
</div>
{{/history}}
+2 -2
View File
@@ -16,9 +16,9 @@
{{#files_folders}}
<li class="Box-row">
<span class="pr-2">{{{icon}}}</span>
<span><a href={{url}}>{{name}}</a></span>
<span><a href="{{url}}">{{name}}</a></span>
{{#allow_editing}}
{{#is_file}}<button class="btn btn-sm float-right delete-file" data-file-path={{name}} data-confirm="Are you sure you want to delete {{name}}?">{{#octicon}}trashcan{{/octicon}}</button>{{/is_file}}
{{#is_file}}<button class="btn btn-sm float-right delete-file" data-file-path="{{url}}" data-confirm="Are you sure you want to delete {{name}}?">{{#octicon}}trashcan{{/octicon}}</button>{{/is_file}}
{{/allow_editing}}
</li>
{{/files_folders}}
+2 -3
View File
@@ -13,9 +13,8 @@
<div class="Box-header border-bottom p-0"></div>
{{#results}}
<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>&nbsp;
<span class="text-bold"><a href="{{base_url}}/{{name}}">{{name}}</a></span>
<span class="Counter Counter--gray tooltipped tooltipped-w" aria-label="{{filename_count}} hits in filename - {{count}} hits in content">{{filename_count}} - {{count}}</span>&nbsp;
<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>
</li>
+1 -1
View File
@@ -36,7 +36,7 @@
</div>
</div>
{{/has_footer}}
</div>
</div>
+38
View File
@@ -0,0 +1,38 @@
require_relative 'compare.rb'
module Precious
module Views
class Commit < Compare
attr_reader :version
def title
"Changes in #{@version[0..6]}: #{message}"
end
def author
@commit.author.name
end
def authored_date
@commit.authored_date
end
def message
@commit.message
end
def files
files = @diff.split(%r{^diff --git a/.+ b/.+$}).reject(&:empty?)
files.map do |diff|
matched = diff.match(%r{(?<=^--- a/).+$})
matched = diff.match(%r{(?<=^\+\+\+ b/).+$}) if matched.nil?
{
path: matched[0],
lines: lines(diff)
}
end
end
end
end
end
+3 -3
View File
@@ -17,9 +17,9 @@ module Precious
@versions[1][0..6]
end
def lines
def lines(diff = @diff)
lines = []
lines_to_parse = @diff.split("\n")[4..-1]
lines_to_parse = diff.split("\n")[4..-1]
# If the diff is of a rename, the diff header will be one line longer than normal because it will contain a line starting with '+++' to indicate the 'new' filename.
# Make sure to skip that header line if it is present.
lines_to_parse = lines_to_parse[1..-1] if lines_to_parse[0].start_with?('+++')
@@ -28,7 +28,7 @@ module Precious
:class => line_class(line),
:ldln => left_diff_line_number(line),
:rdln => right_diff_line_number(line) }
end if @diff
end if diff
lines
end
-4
View File
@@ -15,9 +15,5 @@ module Precious
def id
@page.sha
end
def full_url_path
::File.join(@base_url, escaped_url_path)
end
end
end
+10 -3
View File
@@ -39,7 +39,7 @@ module Precious
route_path = "#{prefix}/#{path}"
@@route_methods[name.to_s] = route_path
define_method :"#{name.to_s}_path" do
"#{base_url}/#{route_path}".gsub(/\/{2,}/, '/') # remove double slashes
page_route(route_path)
end
end
end
@@ -53,8 +53,15 @@ module Precious
end
end
def page_route(page)
"#{base_url}/#{page}".gsub(/\/{2,}/, '/') # remove double slashes
def page_route(page = nil)
clean_url("/#{@base_url}", page)
end
def clean_url(*url)
url.compact!
return nil if url.empty?
::File.join(*url).gsub(%r{/{2,}}, '/')
end
end
+4 -1
View File
@@ -17,15 +17,18 @@ module Precious
i = @versions.size + 1
@versions.map do |v|
i -= 1
filename = path_for_version(v.tracked_pathname)
{ :id => v.id,
:id7 => v.id[0..6],
:href => page_route("gollum/commit/#{v.id}"),
:href_page => page_route("#{filename}/#{v.id}"),
:num => i,
:selected => @page.version.id == v.id,
:author => v.author.name.respond_to?(:force_encoding) ? v.author.name.force_encoding('UTF-8') : v.author.name,
:message => v.message.respond_to?(:force_encoding) ? v.message.force_encoding('UTF-8') : v.message,
:date => v.authored_date.strftime("%B %d, %Y"),
:user_icon => self.user_icon_code(v.author.email),
:filename => path_for_version(v.tracked_pathname),
:filename => filename,
:date_full => v.authored_date,
}
end
+1
View File
@@ -16,6 +16,7 @@ module Precious
i -= 1
{ :id => v.id,
:id7 => v.id[0..6],
:href => page_route("gollum/commit/#{v.id}"),
:num => i,
:author => v.author.name.respond_to?(:force_encoding) ? v.author.name.force_encoding('UTF-8') : v.author.name,
:message => v.message.respond_to?(:force_encoding) ? v.message.force_encoding('UTF-8') : v.message,
+17 -1
View File
@@ -31,7 +31,23 @@ module Precious
end
def custom_path
"#{@base_url}"
@base_url
end
def custom_css
clean_url(custom_path, "custom.css")
end
def custom_js
clean_url(custom_path, "custom.js")
end
def mathjax_config_path
page_route(@mathjax_config)
end
def mathjax_js
page_route("gollum/assets/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML")
end
def css # custom css
+1 -1
View File
@@ -52,7 +52,7 @@ module Precious
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 result_path != '.gitkeep'
file_url = "#{@base_url}/#{result.escaped_url_path}"
file_url = page_route(result.escaped_url_path)
files_and_folders << {name: result.filename, icon: rocticon('file'), type: 'file', url: file_url, is_file: true}
end
end
+4
View File
@@ -169,6 +169,10 @@ module Precious
@navbar
end
def full_url_path
page_route(@page.escaped_url_path)
end
# Access to embedded metadata.
#
# Returns Hash.
+2 -1
View File
@@ -5,7 +5,7 @@ module Precious
include Pagination
def results
@results.sort do |a, b|
sorted = @results.sort do |a, b|
if b.nil?
b_filename_count = 0
b_count = 0
@@ -15,6 +15,7 @@ module Precious
end
[a[:filename_count], a[:count]] <=> [b_filename_count, b_count]
end.reverse.slice((@page_num - 1) * @max_count, @max_count)
sorted.each {|x| x[:href] = page_route(x[:name])}
end
def query_string
+8 -3
View File
@@ -957,12 +957,17 @@ context 'Frontend with base path' do
end
test 'compare view' do
post '/wiki/gollum/compare/Bilbo-Baggins.md', :versions => ['f25eccd98e9b667f9e22946f3e2f945378b8a72d', '5bc1aaec6149e854078f1d0f8b71933bbc6c2e43']
get '/wiki/gollum/compare/Bilbo-Baggins.md?versions[]=f25eccd98e9b667f9e22946f3e2f945378b8a72d&versions[]=5bc1aaec6149e854078f1d0f8b71933bbc6c2e43'
follow_redirect!
assert last_response.ok?
assert_equal '/wiki/gollum/compare/Bilbo-Baggins.md/5bc1aaec6149e854078f1d0f8b71933bbc6c2e43...f25eccd98e9b667f9e22946f3e2f945378b8a72d', last_request.fullpath
post '/wiki/gollum/compare/Bilbo-Baggins.md', :versions => ['f25eccd98e9b667f9e22946f3e2f945378b8a72d']
get '/wiki/gollum/compare/Bilbo-Baggins.md?versions[]=f25eccd98e9b667f9e22946f3e2f945378b8a72d'
follow_redirect!
assert last_response.ok?
assert_equal '/wiki/gollum/compare/Bilbo-Baggins.md/b0d108328459e44fff4a76cd19b10ddc34adce4b...f25eccd98e9b667f9e22946f3e2f945378b8a72d', last_request.fullpath
get '/wiki/gollum/compare/Bilbo-Baggins.md'
follow_redirect!
assert last_response.ok?
assert_equal '/wiki/gollum/history/Bilbo-Baggins.md', last_request.fullpath
@@ -971,4 +976,4 @@ context 'Frontend with base path' do
def app
Precious::MapGollum.new(@base_path)
end
end
end