Namespace (#1328)
* CSS to SCSS * Use sprockets * Use Sprockets helpers * Fix gollum.editor.js error when changing language * Add keybinding files required by ace and some ace ext files that are required or might be useful. * Move app paths to /gollum namespace, add route helpers for view templates * Use path helper for links in page view * Use path helper methods in javascript assets * Refactored sprockets helpers for mustache * Remove debugging
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
if RUBY_PLATFORM == 'java'
|
if RUBY_PLATFORM == 'java'
|
||||||
gem 'gollum-rjgit_adapter', :git => 'https://github.com/repotag/gollum-lib_rjgit_adapter' # For development purposes
|
gem 'gollum-rjgit_adapter', :git => 'https://github.com/repotag/gollum-lib_rjgit_adapter' # For development purposes
|
||||||
gem 'warbler'
|
gem 'warbler'
|
||||||
@@ -7,6 +9,5 @@ end
|
|||||||
|
|
||||||
gem 'gollum-lib', :git => 'https://github.com/gollum/gollum-lib.git', :branch => 'gollum-lib-5.x' # For development purposes
|
gem 'gollum-lib', :git => 'https://github.com/gollum/gollum-lib.git', :branch => 'gollum-lib-5.x' # For development purposes
|
||||||
|
|
||||||
source 'https://rubygems.org'
|
|
||||||
gemspec
|
gemspec
|
||||||
gem 'rake', '~> 11.2'
|
gem 'rake', '~> 11.2'
|
||||||
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|||||||
s.add_dependency 'gollum-lib', '~> 5.0.a'
|
s.add_dependency 'gollum-lib', '~> 5.0.a'
|
||||||
s.add_dependency 'kramdown', '~> 1.17.0'
|
s.add_dependency 'kramdown', '~> 1.17.0'
|
||||||
s.add_dependency 'sinatra', '~> 2.0'
|
s.add_dependency 'sinatra', '~> 2.0'
|
||||||
|
s.add_dependency 'sinatra-contrib', '~> 2.0'
|
||||||
s.add_dependency 'mustache', ['>= 0.99.5', '< 1.0.0']
|
s.add_dependency 'mustache', ['>= 0.99.5', '< 1.0.0']
|
||||||
s.add_dependency 'useragent', '~> 0.16.2'
|
s.add_dependency 'useragent', '~> 0.16.2'
|
||||||
s.add_dependency 'gemojione', '~> 3.2'
|
s.add_dependency 'gemojione', '~> 3.2'
|
||||||
|
|||||||
+31
-26
@@ -1,6 +1,7 @@
|
|||||||
# ~*~ encoding: utf-8 ~*~
|
# ~*~ encoding: utf-8 ~*~
|
||||||
require 'cgi'
|
require 'cgi'
|
||||||
require 'sinatra'
|
require 'sinatra'
|
||||||
|
require 'sinatra/namespace'
|
||||||
require 'gollum-lib'
|
require 'gollum-lib'
|
||||||
require 'mustache/sinatra'
|
require 'mustache/sinatra'
|
||||||
require 'stringex'
|
require 'stringex'
|
||||||
@@ -47,11 +48,12 @@ end
|
|||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# See the wiki.rb file for more details on wiki options
|
# See the wiki.rb file for more details on wiki options
|
||||||
|
|
||||||
module Precious
|
module Precious
|
||||||
class App < Sinatra::Base
|
class App < Sinatra::Base
|
||||||
register Mustache::Sinatra
|
register Mustache::Sinatra
|
||||||
|
register Sinatra::Namespace
|
||||||
include Precious::Helpers
|
include Precious::Helpers
|
||||||
|
|
||||||
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)
|
||||||
@@ -97,6 +99,7 @@ module Precious
|
|||||||
|
|
||||||
Sprockets::Helpers.configure do |config|
|
Sprockets::Helpers.configure do |config|
|
||||||
config.environment = settings.sprockets
|
config.environment = settings.sprockets
|
||||||
|
config.environment.context_class.class_variable_set(:@@base_url, @base_url)
|
||||||
config.prefix = "#{@base_url}/#{Precious::Assets::ASSET_URL}"
|
config.prefix = "#{@base_url}/#{Precious::Assets::ASSET_URL}"
|
||||||
config.digest = @use_static_assets
|
config.digest = @use_static_assets
|
||||||
if @use_static_assets
|
if @use_static_assets
|
||||||
@@ -110,6 +113,8 @@ module Precious
|
|||||||
redirect clean_url(::File.join(@base_url, @page_dir, wiki_new.index_page))
|
redirect clean_url(::File.join(@base_url, @page_dir, wiki_new.index_page))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
namespace '/gollum' do
|
||||||
|
|
||||||
get '/assets/*' do
|
get '/assets/*' do
|
||||||
env['PATH_INFO'].sub!("/#{Precious::Assets::ASSET_URL}", '')
|
env['PATH_INFO'].sub!("/#{Precious::Assets::ASSET_URL}", '')
|
||||||
if @use_static_assets
|
if @use_static_assets
|
||||||
@@ -171,7 +176,7 @@ module Precious
|
|||||||
@content = page.text_data
|
@content = page.text_data
|
||||||
mustache :edit
|
mustache :edit
|
||||||
else
|
else
|
||||||
redirect to("/create/#{encodeURIComponent(@name)}")
|
redirect_to("/create/#{encodeURIComponent(@name)}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -234,7 +239,7 @@ module Precious
|
|||||||
wiki.delete_file(filepath, commit)
|
wiki.delete_file(filepath, commit)
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect to('/pages')
|
redirect_to('/pages')
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/rename/*' do
|
post '/rename/*' do
|
||||||
@@ -419,9 +424,9 @@ module Precious
|
|||||||
@file = encodeURIComponent(params[:splat].first)
|
@file = encodeURIComponent(params[:splat].first)
|
||||||
@versions = params[:versions] || []
|
@versions = params[:versions] || []
|
||||||
if @versions.size < 2
|
if @versions.size < 2
|
||||||
redirect to("/history/#{@file}")
|
redirect_to("/history/#{@file}")
|
||||||
else
|
else
|
||||||
redirect to("/compare/%s/%s...%s" % [
|
redirect_to("/compare/%s/%s...%s" % [
|
||||||
@file,
|
@file,
|
||||||
@versions.last,
|
@versions.last,
|
||||||
@versions.first]
|
@versions.first]
|
||||||
@@ -448,26 +453,6 @@ module Precious
|
|||||||
mustache :compare
|
mustache :compare
|
||||||
end
|
end
|
||||||
|
|
||||||
get %r{/(.+?)/([0-9a-f]{40})} do
|
|
||||||
file_path = params[:captures][0]
|
|
||||||
version = params[:captures][1]
|
|
||||||
wikip = wiki_page(file_path, file_path, version)
|
|
||||||
name = join_page_name(wikip.name, wikip.ext)
|
|
||||||
path = wikip.path
|
|
||||||
if page = wikip.page
|
|
||||||
@page = page
|
|
||||||
@name = name
|
|
||||||
@content = page.formatted_data
|
|
||||||
@version = version
|
|
||||||
@bar_side = wikip.wiki.bar_side
|
|
||||||
mustache :page
|
|
||||||
elsif file = wikip.wiki.file("#{file_path}", version, true)
|
|
||||||
show_file(file)
|
|
||||||
else
|
|
||||||
halt 404
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
get '/search' do
|
get '/search' do
|
||||||
@query = params[:q] || ''
|
@query = params[:q] || ''
|
||||||
wiki = wiki_new
|
wiki = wiki_new
|
||||||
@@ -492,7 +477,27 @@ module Precious
|
|||||||
@ref = wiki.ref
|
@ref = wiki.ref
|
||||||
mustache :pages
|
mustache :pages
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
get %r{/(.+?)/([0-9a-f]{40})} do
|
||||||
|
file_path = params[:captures][0]
|
||||||
|
version = params[:captures][1]
|
||||||
|
wikip = wiki_page(file_path, file_path, version)
|
||||||
|
name = join_page_name(wikip.name, wikip.ext)
|
||||||
|
path = wikip.path
|
||||||
|
if page = wikip.page
|
||||||
|
@page = page
|
||||||
|
@name = name
|
||||||
|
@content = page.formatted_data
|
||||||
|
@version = version
|
||||||
|
@bar_side = wikip.wiki.bar_side
|
||||||
|
mustache :page
|
||||||
|
elsif file = wikip.wiki.file("#{file_path}", version, true)
|
||||||
|
show_file(file)
|
||||||
|
else
|
||||||
|
halt 404
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
get '/*' do
|
get '/*' do
|
||||||
show_page_or_file(params[:splat].first)
|
show_page_or_file(params[:splat].first)
|
||||||
@@ -525,7 +530,7 @@ module Precious
|
|||||||
else
|
else
|
||||||
if @allow_editing
|
if @allow_editing
|
||||||
page_path = [path, join_page_name(name, ext)].compact.join('/')
|
page_path = [path, join_page_name(name, ext)].compact.join('/')
|
||||||
redirect to("/create/#{clean_url(encodeURIComponent(page_path))}")
|
redirect to("/gollum/create/#{clean_url(encodeURIComponent(page_path))}")
|
||||||
else
|
else
|
||||||
@message = "The requested page does not exist."
|
@message = "The requested page does not exist."
|
||||||
status 404
|
status 404
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module Precious
|
module Precious
|
||||||
module Assets
|
module Assets
|
||||||
MANIFEST = %w(app.js app.css fileview.css ie7.css print.css *.png *.jpg *.svg *.eot *.ttf *.woff *.woff2)
|
MANIFEST = %w(app.js app.css fileview.css ie7.css print.css *.png *.jpg *.svg *.eot *.ttf *.woff *.woff2)
|
||||||
ASSET_URL = 'assets'
|
ASSET_URL = 'gollum/assets'
|
||||||
|
|
||||||
def self.sprockets(dir = File.dirname(File.expand_path(__FILE__)))
|
def self.sprockets(dir = File.dirname(File.expand_path(__FILE__)))
|
||||||
env = Sprockets::Environment.new
|
env = Sprockets::Environment.new
|
||||||
@@ -12,6 +12,13 @@ module Precious
|
|||||||
|
|
||||||
env.js_compressor = :uglify
|
env.js_compressor = :uglify
|
||||||
env.css_compressor = :scss
|
env.css_compressor = :scss
|
||||||
|
|
||||||
|
env.context_class.class_eval do
|
||||||
|
def base_url
|
||||||
|
self.class.class_variable_get(:@@base_url)
|
||||||
|
end
|
||||||
|
include ::Precious::Views::RouteHelpers
|
||||||
|
end
|
||||||
env
|
env
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+1
-1
@@ -209,7 +209,7 @@
|
|||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: baseUrl + '/uploadFile',
|
url: '<%= upload_file_path %>',
|
||||||
data: formData,
|
data: formData,
|
||||||
cache: false,
|
cache: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
+11
-7
@@ -47,7 +47,7 @@ $(document).ready(function() {
|
|||||||
$('#delete-link').click( function(e) {
|
$('#delete-link').click( function(e) {
|
||||||
var ok = confirm($(this).data('confirm'));
|
var ok = confirm($(this).data('confirm'));
|
||||||
if ( ok ) {
|
if ( ok ) {
|
||||||
var loc = baseUrl + '/delete/' + pageFullPath;
|
var loc = '<%= delete_path %>/' + pageFullPath;
|
||||||
window.location = loc;
|
window.location = loc;
|
||||||
}
|
}
|
||||||
// Don't navigate on cancel.
|
// Don't navigate on cancel.
|
||||||
@@ -162,7 +162,7 @@ $(document).ready(function() {
|
|||||||
{
|
{
|
||||||
type: 'file',
|
type: 'file',
|
||||||
context: 'Your uploaded file will be accessible at<br>/'+uploadDest+'/[filename]',
|
context: 'Your uploaded file will be accessible at<br>/'+uploadDest+'/[filename]',
|
||||||
action: baseUrl + '/uploadFile'
|
action: '<%= upload_file_path %>'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
OK: function( res ) {
|
OK: function( res ) {
|
||||||
@@ -226,10 +226,14 @@ $(document).ready(function() {
|
|||||||
// In the pages view, pageFullPath isn't defined.
|
// In the pages view, pageFullPath isn't defined.
|
||||||
// The new button will still expect a value however.
|
// The new button will still expect a value however.
|
||||||
// So we try to figure one out from window.location
|
// So we try to figure one out from window.location
|
||||||
path = baseUrl == '' ? window.location.pathname.substr(1)
|
path = window.location.pathname.substr(1)
|
||||||
: window.location.pathname.substr(baseUrl.length + 1);
|
|
||||||
// Remove the page viewer part of the url.
|
// Remove the page viewer part of the url.
|
||||||
path = path.replace(/^pages\/?/,'')
|
<%
|
||||||
|
pages_path_uri = pages_path
|
||||||
|
pages_path_uri = pages_path_uri[1..-1] if pages_path_uri[0] == '/'
|
||||||
|
pages_path_uri = pages_path_uri.gsub('/','\/')
|
||||||
|
%>
|
||||||
|
path = path.replace(/^<%= pages_path_uri %>\/?/,'')
|
||||||
// For consistency remove the trailing /
|
// For consistency remove the trailing /
|
||||||
path = path.replace(/\/$/,'')
|
path = path.replace(/\/$/,'')
|
||||||
}
|
}
|
||||||
@@ -260,7 +264,7 @@ $(document).ready(function() {
|
|||||||
for( var i=0; i < name_parts.length; i++ ){
|
for( var i=0; i < name_parts.length; i++ ){
|
||||||
name_encoded.push(encodeURIComponent(name_parts[i]));
|
name_encoded.push(encodeURIComponent(name_parts[i]));
|
||||||
}
|
}
|
||||||
window.location = baseUrl + name_encoded.join('/');
|
window.location = '<%= create_path %>' + name_encoded.join('/');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -315,7 +319,7 @@ $(document).ready(function() {
|
|||||||
if( $("#last-edit").length ) {
|
if( $("#last-edit").length ) {
|
||||||
$("#page-info-toggle").click ( function () {
|
$("#page-info-toggle").click ( function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/last-commit-info',
|
url: '<%= last_commit_info_path %>',
|
||||||
data: {path: $("#page-info-toggle").data('pagepath')},
|
data: {path: $("#page-info-toggle").data('pagepath')},
|
||||||
success: function ( data ) {
|
success: function ( data ) {
|
||||||
$("#last-edit").html('Last edited by <b>' + data.author + '</b>, ' + data.date);
|
$("#last-edit").html('Last edited by <b>' + data.author + '</b>, ' + data.date);
|
||||||
@@ -9,10 +9,10 @@
|
|||||||
<li class="minibutton"><a href="{{base_url}}/{{escaped_url_path}}"
|
<li class="minibutton"><a href="{{base_url}}/{{escaped_url_path}}"
|
||||||
class="action-view-page">View Page</a></li>
|
class="action-view-page">View Page</a></li>
|
||||||
{{#allow_editing}}
|
{{#allow_editing}}
|
||||||
<li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
|
<li class="minibutton"><a href="{{edit_path}}/{{escaped_url_path}}"
|
||||||
class="action-edit-page">Edit Page</a></li>
|
class="action-edit-page">Edit Page</a></li>
|
||||||
{{/allow_editing}}
|
{{/allow_editing}}
|
||||||
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
|
<li class="minibutton"><a href="{{history_path}}/{{escaped_url_path}}"
|
||||||
class="action-page-history">Page History</a></li>
|
class="action-page-history">Page History</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -25,11 +25,11 @@
|
|||||||
|
|
||||||
{{#show_revert}}
|
{{#show_revert}}
|
||||||
<ul class="actions">
|
<ul class="actions">
|
||||||
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
|
<li class="minibutton"><a href="{{history_path}}/{{escaped_url_path}}"
|
||||||
class="action-page-history">Back to Page History</a></li>
|
class="action-page-history">Back to Page History</a></li>
|
||||||
{{#allow_editing}}
|
{{#allow_editing}}
|
||||||
<li class="minibutton">
|
<li class="minibutton">
|
||||||
<form name="gollum-revert" action="{{base_url}}/revert/{{escaped_url_path}}/{{before}}/{{after}}" method="post" id="gollum-revert-form">
|
<form name="gollum-revert" action="{{revert_path}}/{{escaped_url_path}}/{{before}}/{{after}}" method="post" id="gollum-revert-form">
|
||||||
<a href="#" class="gollum-revert-button">Revert Changes</a>
|
<a href="#" class="gollum-revert-button">Revert Changes</a>
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
<ul class="actions">
|
<ul class="actions">
|
||||||
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
|
<li class="minibutton"><a href="{{history_path}}/{{escaped_url_path}}"
|
||||||
class="action-page-history">Back to Page History</a></li>
|
class="action-page-history">Back to Page History</a></li>
|
||||||
{{#show_revert}}
|
{{#show_revert}}
|
||||||
{{#allow_editing}}
|
{{#allow_editing}}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<ul class="actions">
|
<ul class="actions">
|
||||||
<li class="minibutton"><a href="{{base_url}}/{{escaped_url_path}}"
|
<li class="minibutton"><a href="{{base_url}}/{{escaped_url_path}}"
|
||||||
class="action-view-page">View Page</a></li>
|
class="action-view-page">View Page</a></li>
|
||||||
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
|
<li class="minibutton"><a href="{{history_path}}/{{escaped_url_path}}"
|
||||||
class="action-page-history">Page History</a></li>
|
class="action-page-history">Page History</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<div id="gollum-editor" data-escaped-name="{{escaped_name}}" class="{{#is_create_page}}create{{/is_create_page}}{{#is_edit_page}}edit{{/is_edit_page}} {{#allow_uploads}}uploads-allowed{{/allow_uploads}}">
|
<div id="gollum-editor" data-escaped-name="{{escaped_name}}" class="{{#is_create_page}}create{{/is_create_page}}{{#is_edit_page}}edit{{/is_edit_page}} {{#allow_uploads}}uploads-allowed{{/allow_uploads}}">
|
||||||
{{#is_create_page}}
|
{{#is_create_page}}
|
||||||
<form name="gollum-editor" action="{{base_url}}/create" method="post">
|
<form name="gollum-editor" action="{{create_path}}" method="post">
|
||||||
{{/is_create_page}}
|
{{/is_create_page}}
|
||||||
{{#is_edit_page}}
|
{{#is_edit_page}}
|
||||||
<form name="gollum-editor" action="{{base_url}}/edit/{{escaped_name}}" method="post">
|
<form name="gollum-editor" action="{{edit_path}}/{{escaped_name}}" method="post">
|
||||||
{{/is_edit_page}}
|
{{/is_edit_page}}
|
||||||
<fieldset id="gollum-editor-fields">
|
<fieldset id="gollum-editor-fields">
|
||||||
{{#is_create_page}}
|
{{#is_create_page}}
|
||||||
@@ -147,7 +147,7 @@
|
|||||||
<span class="jaws"><br></span>
|
<span class="jaws"><br></span>
|
||||||
<input type="submit" id="gollum-editor-submit" value="Save" title="Save current changes">
|
<input type="submit" id="gollum-editor-submit" value="Save" title="Save current changes">
|
||||||
<a href="" id="gollum-editor-cancel" class="minibutton" title="Cancel editing" onClick="window.history.back()">Cancel</a>
|
<a href="" id="gollum-editor-cancel" class="minibutton" title="Cancel editing" onClick="window.history.back()">Cancel</a>
|
||||||
<a href="{{base_url}}/preview" id="gollum-editor-preview" class="minibutton" title="Preview this Page">Preview</a>
|
<a href="{{preview_path}}" id="gollum-editor-preview" class="minibutton" title="Preview this Page">Preview</a>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<li class="minibutton"><a href="{{base_url}}/{{escaped_url_path}}"
|
<li class="minibutton"><a href="{{base_url}}/{{escaped_url_path}}"
|
||||||
class="action-view-page">View Page</a></li>
|
class="action-view-page">View Page</a></li>
|
||||||
{{#allow_editing}}
|
{{#allow_editing}}
|
||||||
<li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
|
<li class="minibutton"><a href="{{edit_path}}/{{escaped_url_path}}"
|
||||||
class="action-edit-page">Edit Page</a></li>
|
class="action-edit-page">Edit Page</a></li>
|
||||||
{{/allow_editing}}
|
{{/allow_editing}}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<form name="compare-versions" id="version-form" method="post"
|
<form name="compare-versions" id="version-form" method="post"
|
||||||
action="{{base_url}}/compare/{{escaped_url_path}}">
|
action="{{compare_path}}/{{escaped_url_path}}">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<a href="javascript:void(0)">
|
<a href="javascript:void(0)">
|
||||||
<img src="{{#image_path_mustache}}man_24.png{{/image_path_mustache}}" alt="avatar: {{author}}"
|
<img src="{{#sprockets_image_path}}man_24.png{{/sprockets_image_path}}" alt="avatar: {{author}}"
|
||||||
class="mini-gravatar identicon" data-identicon="{{identicon}}"/>
|
class="mini-gravatar identicon" data-identicon="{{identicon}}"/>
|
||||||
<span class="username">{{author}}</span>
|
<span class="username">{{author}}</span>
|
||||||
</a>
|
</a>
|
||||||
@@ -5,13 +5,13 @@
|
|||||||
<meta name="MobileOptimized" content="width">
|
<meta name="MobileOptimized" content="width">
|
||||||
<meta name="HandheldFriendly" content="true">
|
<meta name="HandheldFriendly" content="true">
|
||||||
<meta name="viewport" content="width=device-width">
|
<meta name="viewport" content="width=device-width">
|
||||||
{{#stylesheet_tag_mustache}}app media: :all{{/stylesheet_tag_mustache}}
|
{{#sprockets_stylesheet_tag}}app{{/sprockets_stylesheet_tag}}
|
||||||
{{#stylesheet_tag_mustache}}print media: :print{{/stylesheet_tag_mustache}}
|
{{#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_path}}/custom.css" media="all">{{/css}}
|
||||||
{{#noindex}}<meta name="robots" content="noindex, nofollow" />{{/noindex}}
|
{{#noindex}}<meta name="robots" content="noindex, nofollow" />{{/noindex}}
|
||||||
|
|
||||||
<!--[if lte IE 8]>
|
<!--[if lte IE 8]>
|
||||||
{{#stylesheet_tag_mustache}}ie7 media: :all{{/stylesheet_tag_mustache}}
|
{{#sprockets_stylesheet_tag}}ie7{{/sprockets_stylesheet_tag}}
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -21,9 +21,9 @@
|
|||||||
var pageFullPath = '{{url_path}}';
|
var pageFullPath = '{{url_path}}';
|
||||||
{{/page}}
|
{{/page}}
|
||||||
</script>
|
</script>
|
||||||
{{#javascript_tag_mustache}}app{{/javascript_tag_mustache}}
|
{{#sprockets_javascript_tag}}app{{/sprockets_javascript_tag}}
|
||||||
{{#use_identicon}}
|
{{#use_identicon}}
|
||||||
{{#javascript_tag_mustache}}identicon_canvas{{/javascript_tag_mustache}}
|
{{#sprockets_javascript_tag}}identicon_canvas{{/sprockets_javascript_tag}}
|
||||||
{{/use_identicon}}
|
{{/use_identicon}}
|
||||||
{{#mathjax}}
|
{{#mathjax}}
|
||||||
{{^mathjax_config}}
|
{{^mathjax_config}}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Mousetrap.bind(['e'], function( e ) {
|
|||||||
</li>
|
</li>
|
||||||
<li class="minibutton"><a href="{{base_url}}/"
|
<li class="minibutton"><a href="{{base_url}}/"
|
||||||
class="action-home-page">Home</a></li>
|
class="action-home-page">Home</a></li>
|
||||||
<li class="minibutton"><a href="{{base_url}}/pages"
|
<li class="minibutton"><a href="{{pages_path}}"
|
||||||
class="action-all-pages">Overview</a></li>
|
class="action-all-pages">Overview</a></li>
|
||||||
{{#allow_editing}}
|
{{#allow_editing}}
|
||||||
<li class="minibutton jaws">
|
<li class="minibutton jaws">
|
||||||
@@ -34,13 +34,13 @@ Mousetrap.bind(['e'], function( e ) {
|
|||||||
{{/allow_editing}}
|
{{/allow_editing}}
|
||||||
{{#allow_editing}}
|
{{#allow_editing}}
|
||||||
{{#editable}}
|
{{#editable}}
|
||||||
<li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
|
<li class="minibutton"><a href="{{edit_path}}/{{escaped_url_path}}"
|
||||||
class="action-edit-page">Edit</a></li>
|
class="action-edit-page">Edit</a></li>
|
||||||
{{/editable}}
|
{{/editable}}
|
||||||
{{/allow_editing}}
|
{{/allow_editing}}
|
||||||
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
|
<li class="minibutton"><a href="{{history_path}}/{{escaped_url_path}}"
|
||||||
class="action-page-history">History</a></li>
|
class="action-page-history">History</a></li>
|
||||||
<li class="minibutton"><a href="{{base_url}}/latest_changes"
|
<li class="minibutton"><a href="{{latest_changes_path}}"
|
||||||
class="action-page-history">Latest Changes</a></li>
|
class="action-page-history">Latest Changes</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -91,7 +91,7 @@ Mousetrap.bind(['e'], function( e ) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form name="rename" method="POST" action="{{base_url}}/rename/{{escaped_url_path}}">
|
<form name="rename" method="POST" action="{{rename_path}}/{{escaped_url_path}}">
|
||||||
<input type="hidden" name="rename"/>
|
<input type="hidden" name="rename"/>
|
||||||
<input type="hidden" name="message"/>
|
<input type="hidden" name="message"/>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div id="searchbar">
|
<div id="searchbar">
|
||||||
<form action="{{base_url}}/search" method="get" id="search-form">
|
<form action="{{search_path}}" method="get" id="search-form">
|
||||||
<div id="searchbar-fauxtext">
|
<div id="searchbar-fauxtext">
|
||||||
<input type="text" name="q" id="search-query" value="Search…" autocomplete="off">
|
<input type="text" name="q" id="search-query" value="Search…" autocomplete="off">
|
||||||
<a href="#" id="search-submit" title="Search this wiki">
|
<a href="#" id="search-submit" title="Search this wiki">
|
||||||
|
|||||||
+47
-15
@@ -2,31 +2,63 @@ require 'yaml'
|
|||||||
|
|
||||||
module Precious
|
module Precious
|
||||||
module Views
|
module Views
|
||||||
|
module RouteHelpers
|
||||||
|
ROUTES = {
|
||||||
|
'gollum' => {
|
||||||
|
last_commit_info: 'last-commit-info',
|
||||||
|
latest_changes: 'latest_changes',
|
||||||
|
upload_file: 'uploadFile',
|
||||||
|
create: 'create',
|
||||||
|
delete: 'delete',
|
||||||
|
edit: 'edit',
|
||||||
|
pages: 'pages',
|
||||||
|
history: 'history',
|
||||||
|
rename: 'rename',
|
||||||
|
preview: 'preview',
|
||||||
|
compare: 'compare',
|
||||||
|
search: 'search'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def self.parse_routes(routes, prefix = '')
|
||||||
|
routes.each do |name, path|
|
||||||
|
if path.respond_to?(:keys)
|
||||||
|
self.parse_routes(path, "#{prefix}/#{name}")
|
||||||
|
else
|
||||||
|
define_method :"#{name.to_s}_path" do
|
||||||
|
"#{base_url}/#{prefix}/#{path}".gsub(/\/{2,}/, '/') # remove double slashes
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.included(base)
|
||||||
|
self.parse_routes(ROUTES)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
module SprocketsHelpers
|
module SprocketsHelpers
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
|
|
||||||
def helper_proc_with_options(method)
|
def sprockets_stylesheet_tag
|
||||||
Proc.new do |args|
|
lambda do |args|
|
||||||
args = args.split(' ')
|
args = args.split(' ')
|
||||||
if args.size > 1 then
|
name = args[0]
|
||||||
options = args[1..-1].join(' ')
|
options = {:media => :all}
|
||||||
options = YAML.safe_load("---\n#{options}\n", [Symbol])
|
options[:media] = :print if args[1] == 'print'
|
||||||
end
|
send(:stylesheet_tag, name, options)
|
||||||
options = options.respond_to?(:to_h) ? options.to_h : {}
|
|
||||||
options = options.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
|
||||||
send(method, args[0], options)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
['stylesheet_path','javascript_path', 'image_path'].each do |method|
|
def sprockets_javascript_tag
|
||||||
define_method :"#{method}_mustache" do
|
lambda do |name|
|
||||||
Proc.new {|args| send(method.to_sym, args)}
|
send(:javascript_tag, name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
['stylesheet_tag','javascript_tag'].each do |method|
|
def sprockets_image_path
|
||||||
define_method :"#{method}_mustache" do
|
lambda do |args|
|
||||||
helper_proc_with_options(method.to_sym)
|
send(:image_path, name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ module Precious
|
|||||||
include Rack::Utils
|
include Rack::Utils
|
||||||
include Sprockets::Helpers
|
include Sprockets::Helpers
|
||||||
include Precious::Views::SprocketsHelpers
|
include Precious::Views::SprocketsHelpers
|
||||||
|
include Precious::Views::RouteHelpers
|
||||||
|
|
||||||
alias_method :h, :escape_html
|
alias_method :h, :escape_html
|
||||||
|
|
||||||
attr_reader :name, :path
|
attr_reader :name, :path
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ module Precious
|
|||||||
# result contains a folder
|
# result contains a folder
|
||||||
folder = result_path.split('/').first
|
folder = result_path.split('/').first
|
||||||
folder_path = @path ? "#{@path}/#{folder}" : folder
|
folder_path = @path ? "#{@path}/#{folder}" : folder
|
||||||
folder_link = %{<li><a href="#{@base_url}/pages/#{folder_path}/" class="folder">#{folder}</a></li>}
|
folder_link = %{<li><a href="#{pages_path}/#{folder_path}/" class="folder">#{folder}</a></li>}
|
||||||
|
|
||||||
folders[folder] = folder_link unless folders.key?(folder)
|
folders[folder] = folder_link unless folders.key?(folder)
|
||||||
elsif result_path != ".gitkeep"
|
elsif result_path != ".gitkeep"
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ context "Precious::Views::Editing" do
|
|||||||
|
|
||||||
test "creating page is blocked" do
|
test "creating page is blocked" do
|
||||||
Precious::App.set(:wiki_options, { allow_editing: false})
|
Precious::App.set(:wiki_options, { allow_editing: false})
|
||||||
post "/create", :content => 'abc', :page => "D",
|
post "/gollum/create", :content => 'abc', :page => "D",
|
||||||
:format => 'markdown', :message => 'def'
|
:format => 'markdown', :message => 'def'
|
||||||
assert !last_response.ok?
|
assert !last_response.ok?
|
||||||
|
|
||||||
@@ -36,15 +36,15 @@ context "Precious::Views::Editing" do
|
|||||||
assert_match /Rename/, last_response.body, "'Rename' link is blocked in page template"
|
assert_match /Rename/, last_response.body, "'Rename' link is blocked in page template"
|
||||||
assert_match /Edit/, last_response.body, "'Edit' link is blocked in page template"
|
assert_match /Edit/, last_response.body, "'Edit' link is blocked in page template"
|
||||||
|
|
||||||
get '/pages'
|
get '/gollum/pages'
|
||||||
|
|
||||||
assert_match /New/, last_response.body, "'New' link is blocked in pages template"
|
assert_match /New/, last_response.body, "'New' link is blocked in pages template"
|
||||||
|
|
||||||
get '/history/A'
|
get '/gollum/history/A'
|
||||||
|
|
||||||
assert_match /Edit/, last_response.body, "'Edit' link is blocked in history template"
|
assert_match /Edit/, last_response.body, "'Edit' link is blocked in history template"
|
||||||
|
|
||||||
get '/compare/A/fc66539528eb96f21b2bbdbf557788fe8a1196ac..b26b791cb7917c4f37dd9cb4d1e0efb24ac4d26f'
|
get '/gollum/compare/A/fc66539528eb96f21b2bbdbf557788fe8a1196ac..b26b791cb7917c4f37dd9cb4d1e0efb24ac4d26f'
|
||||||
|
|
||||||
assert_match /Edit Page/, last_response.body, "'Edit Page' link is blocked in compare template"
|
assert_match /Edit Page/, last_response.body, "'Edit Page' link is blocked in compare template"
|
||||||
assert_match /Revert Changes/, last_response.body, "'Revert Changes' link is blocked in compare template"
|
assert_match /Revert Changes/, last_response.body, "'Revert Changes' link is blocked in compare template"
|
||||||
@@ -60,15 +60,15 @@ context "Precious::Views::Editing" do
|
|||||||
assert_no_match /Rename/, last_response.body, "'Rename' link not blocked in page template"
|
assert_no_match /Rename/, last_response.body, "'Rename' link not blocked in page template"
|
||||||
assert_no_match /Edit/, last_response.body, "'Edit' link not blocked in page template"
|
assert_no_match /Edit/, last_response.body, "'Edit' link not blocked in page template"
|
||||||
|
|
||||||
get '/pages'
|
get '/gollum/pages'
|
||||||
|
|
||||||
assert_no_match /New/, last_response.body, "'New' link not blocked in pages template"
|
assert_no_match /New/, last_response.body, "'New' link not blocked in pages template"
|
||||||
|
|
||||||
get '/history/A'
|
get '/gollum/history/A'
|
||||||
|
|
||||||
assert_no_match /Edit/, last_response.body, "'Edit' link not blocked in history template"
|
assert_no_match /Edit/, last_response.body, "'Edit' link not blocked in history template"
|
||||||
|
|
||||||
get '/compare/A/fc66539528eb96f21b2bbdbf557788fe8a1196ac..b26b791cb7917c4f37dd9cb4d1e0efb24ac4d26f'
|
get '/gollum/compare/A/fc66539528eb96f21b2bbdbf557788fe8a1196ac..b26b791cb7917c4f37dd9cb4d1e0efb24ac4d26f'
|
||||||
|
|
||||||
assert_no_match /Edit Page/, last_response.body, "'Edit Page' link not blocked in compare template"
|
assert_no_match /Edit Page/, last_response.body, "'Edit Page' link not blocked in compare template"
|
||||||
assert_no_match /Revert Changes/, last_response.body, "'Revert Changes' link not blocked in compare template"
|
assert_no_match /Revert Changes/, last_response.body, "'Revert Changes' link not blocked in compare template"
|
||||||
|
|||||||
+54
-54
@@ -73,13 +73,13 @@ context "Frontend" do
|
|||||||
@wiki.write_page(page1, :markdown, '',
|
@wiki.write_page(page1, :markdown, '',
|
||||||
{ :name => user1, :email => user1 });
|
{ :name => user1, :email => user1 });
|
||||||
|
|
||||||
get "/last-commit-info", :path => page1
|
get "/gollum/last-commit-info", :path => page1
|
||||||
assert_match /\"author\":\"user1\"/, last_response.body
|
assert_match /\"author\":\"user1\"/, last_response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
test "edits page" do
|
test "edits page" do
|
||||||
page_1 = @wiki.page('A')
|
page_1 = @wiki.page('A')
|
||||||
post "/edit/A", :content => 'abc', :page => 'A',
|
post "/gollum/edit/A", :content => 'abc', :page => 'A',
|
||||||
:format => page_1.format, :message => 'def'
|
:format => page_1.format, :message => 'def'
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
@@ -93,7 +93,7 @@ context "Frontend" do
|
|||||||
|
|
||||||
test "edit page with empty message" do
|
test "edit page with empty message" do
|
||||||
page_1 = @wiki.page('A')
|
page_1 = @wiki.page('A')
|
||||||
post "/edit/A", :content => 'abc', :page => 'A',
|
post "/gollum/edit/A", :content => 'abc', :page => 'A',
|
||||||
:format => page_1.format
|
:format => page_1.format
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
@@ -107,7 +107,7 @@ context "Frontend" do
|
|||||||
|
|
||||||
test "edit page with slash" do
|
test "edit page with slash" do
|
||||||
page_1 = @wiki.page('A')
|
page_1 = @wiki.page('A')
|
||||||
post "/edit/A", :content => 'abc', :page => 'A', :path => '/////',
|
post "/gollum/edit/A", :content => 'abc', :page => 'A', :path => '/////',
|
||||||
:format => page_1.format, :message => 'def'
|
:format => page_1.format, :message => 'def'
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
@@ -120,7 +120,7 @@ context "Frontend" do
|
|||||||
foot_1 = page_1.footer
|
foot_1 = page_1.footer
|
||||||
side_1 = page_1.sidebar
|
side_1 = page_1.sidebar
|
||||||
|
|
||||||
post "/edit/A", :header => 'header',
|
post "/gollum/edit/A", :header => 'header',
|
||||||
:footer => 'footer', :page => "A", :sidebar => 'sidebar', :message => 'def'
|
:footer => 'footer', :page => "A", :sidebar => 'sidebar', :message => 'def'
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert_equal "/A.md", last_request.fullpath
|
assert_equal "/A.md", last_request.fullpath
|
||||||
@@ -147,7 +147,7 @@ context "Frontend" do
|
|||||||
|
|
||||||
test "renames page" do
|
test "renames page" do
|
||||||
page_1 = @wiki.page("B")
|
page_1 = @wiki.page("B")
|
||||||
post "/rename/B", :rename => "/C", :message => 'def'
|
post "/gollum/rename/B", :rename => "/C", :message => 'def'
|
||||||
|
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert_equal '/C.md', last_request.fullpath
|
assert_equal '/C.md', last_request.fullpath
|
||||||
@@ -163,21 +163,21 @@ context "Frontend" do
|
|||||||
|
|
||||||
test "renames page catches invalid page" do
|
test "renames page catches invalid page" do
|
||||||
# No such page
|
# No such page
|
||||||
post "/rename/no-such-file-here", :rename => "/C", :message => 'def'
|
post "/gollum/rename/no-such-file-here", :rename => "/C", :message => 'def'
|
||||||
assert !last_response.ok?
|
assert !last_response.ok?
|
||||||
assert_equal last_response.status, 500
|
assert_equal last_response.status, 500
|
||||||
end
|
end
|
||||||
|
|
||||||
test "rename page catches empty target" do
|
test "rename page catches empty target" do
|
||||||
# Empty rename target
|
# Empty rename target
|
||||||
post "/rename/B", :rename => "", :message => 'def'
|
post "/gollum/rename/B", :rename => "", :message => 'def'
|
||||||
assert !last_response.ok?
|
assert !last_response.ok?
|
||||||
assert_equal last_response.status, 500
|
assert_equal last_response.status, 500
|
||||||
end
|
end
|
||||||
|
|
||||||
test "rename page catches non-existent target" do
|
test "rename page catches non-existent target" do
|
||||||
# Non-existent rename target
|
# Non-existent rename target
|
||||||
post "/rename/B", :message => 'def'
|
post "/gollum/rename/B", :message => 'def'
|
||||||
assert !last_response.ok?
|
assert !last_response.ok?
|
||||||
assert_equal last_response.status, 500
|
assert_equal last_response.status, 500
|
||||||
end
|
end
|
||||||
@@ -186,7 +186,7 @@ context "Frontend" do
|
|||||||
test "renames page in subdirectory" do
|
test "renames page in subdirectory" do
|
||||||
page_1 = @wiki.paged("H", "G")
|
page_1 = @wiki.paged("H", "G")
|
||||||
assert_not_equal page_1, nil
|
assert_not_equal page_1, nil
|
||||||
post "/rename/G/H", :rename => "/I/C", :message => 'def'
|
post "/gollum/rename/G/H", :rename => "/I/C", :message => 'def'
|
||||||
|
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert_equal '/I/C.md', last_request.fullpath
|
assert_equal '/I/C.md', last_request.fullpath
|
||||||
@@ -203,7 +203,7 @@ context "Frontend" do
|
|||||||
test "renames page relative in subdirectory" do
|
test "renames page relative in subdirectory" do
|
||||||
page_1 = @wiki.paged("H", "G")
|
page_1 = @wiki.paged("H", "G")
|
||||||
assert_not_equal page_1, nil
|
assert_not_equal page_1, nil
|
||||||
post "/rename/G/H", :rename => "K/C", :message => 'def'
|
post "/gollum/rename/G/H", :rename => "K/C", :message => 'def'
|
||||||
|
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert_equal '/G/K/C.md', last_request.fullpath
|
assert_equal '/G/K/C.md', last_request.fullpath
|
||||||
@@ -219,7 +219,7 @@ context "Frontend" do
|
|||||||
|
|
||||||
|
|
||||||
test "creates page" do
|
test "creates page" do
|
||||||
post "/create", :content => 'abc', :page => "D",
|
post "/gollum/create", :content => 'abc', :page => "D",
|
||||||
:format => 'markdown', :message => 'def'
|
:format => 'markdown', :message => 'def'
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
@@ -230,7 +230,7 @@ context "Frontend" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "creates pages with escaped characters in title" do
|
test "creates pages with escaped characters in title" do
|
||||||
post "/create", :content => 'abc', :page => 'Title with spaces',
|
post "/gollum/create", :content => 'abc', :page => 'Title with spaces',
|
||||||
:format => 'markdown', :message => 'foo'
|
:format => 'markdown', :message => 'foo'
|
||||||
assert_equal 'http://example.org/Title%20with%20spaces.md', last_response.headers['Location']
|
assert_equal 'http://example.org/Title%20with%20spaces.md', last_response.headers['Location']
|
||||||
get "/Title%20with%20spaces"
|
get "/Title%20with%20spaces"
|
||||||
@@ -241,7 +241,7 @@ context "Frontend" do
|
|||||||
name = "E"
|
name = "E"
|
||||||
get "/#{name}"
|
get "/#{name}"
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert_equal "/create/#{name}", last_request.fullpath
|
assert_equal "/gollum/create/#{name}", last_request.fullpath
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -249,12 +249,12 @@ context "Frontend" do
|
|||||||
get "/foo/"
|
get "/foo/"
|
||||||
|
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert_equal "/create/foo/Home", last_request.fullpath
|
assert_equal "/gollum/create/foo/Home", last_request.fullpath
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "accessing redirectory redirects to index page" do
|
test "accessing redirectory redirects to index page" do
|
||||||
post "/create", :content => 'abc', :page => 'Home', :path => '/foo/',
|
post "/gollum/create", :content => 'abc', :page => 'Home', :path => '/foo/',
|
||||||
:format => 'markdown', :message => 'foo'
|
:format => 'markdown', :message => 'foo'
|
||||||
|
|
||||||
assert_equal "http://example.org/foo/Home.md", last_response.headers['Location']
|
assert_equal "http://example.org/foo/Home.md", last_response.headers['Location']
|
||||||
@@ -265,15 +265,15 @@ context "Frontend" do
|
|||||||
|
|
||||||
test "edit redirects to create on non-existant page" do
|
test "edit redirects to create on non-existant page" do
|
||||||
name = "E"
|
name = "E"
|
||||||
get "/edit/#{name}"
|
get "/gollum/edit/#{name}"
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert_equal "/create/#{name}", last_request.fullpath
|
assert_equal "/gollum/create/#{name}", last_request.fullpath
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "create redirects to page if already exists" do
|
test "create redirects to page if already exists" do
|
||||||
name = "A.md"
|
name = "A.md"
|
||||||
get "/create/#{name}"
|
get "/gollum/create/#{name}"
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert_equal "/#{name}", last_request.fullpath
|
assert_equal "/#{name}", last_request.fullpath
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
@@ -282,7 +282,7 @@ context "Frontend" do
|
|||||||
test "create sets the correct path for a relative path subdirectory" do
|
test "create sets the correct path for a relative path subdirectory" do
|
||||||
dir = "foodir"
|
dir = "foodir"
|
||||||
name = "#{dir}/bar"
|
name = "#{dir}/bar"
|
||||||
get "/create/#{name}"
|
get "/gollum/create/#{name}"
|
||||||
assert_match(/\/#{dir}/, last_response.body)
|
assert_match(/\/#{dir}/, last_response.body)
|
||||||
assert_no_match(/[^\/]#{dir}/, last_response.body)
|
assert_no_match(/[^\/]#{dir}/, last_response.body)
|
||||||
end
|
end
|
||||||
@@ -290,21 +290,21 @@ context "Frontend" do
|
|||||||
test "create with template succeed if template exists" do
|
test "create with template succeed if template exists" do
|
||||||
Precious::App.set(:wiki_options, { :template_page => true })
|
Precious::App.set(:wiki_options, { :template_page => true })
|
||||||
page='_Template'
|
page='_Template'
|
||||||
post '/create', :content => 'fake template', :page => page,
|
post '/gollum/create', :content => 'fake template', :page => page,
|
||||||
:path => '/', :format => 'markdown', :message => ''
|
:path => '/', :format => 'markdown', :message => ''
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
#puts last_response
|
#puts last_response
|
||||||
@wiki.clear_cache
|
@wiki.clear_cache
|
||||||
get "/create/TT"
|
get "/gollum/create/TT"
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
get '/delete/_Template'
|
get '/gollum/delete/_Template'
|
||||||
Precious::App.set(:wiki_options, { :template_page => false })
|
Precious::App.set(:wiki_options, { :template_page => false })
|
||||||
end
|
end
|
||||||
|
|
||||||
test "create with template succeed if template doesn't exist" do
|
test "create with template succeed if template doesn't exist" do
|
||||||
Precious::App.set(:wiki_options, { :template_page => true })
|
Precious::App.set(:wiki_options, { :template_page => true })
|
||||||
get "/create/TT"
|
get "/gollum/create/TT"
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
Precious::App.set(:wiki_options, { :template_page => false })
|
Precious::App.set(:wiki_options, { :template_page => false })
|
||||||
end
|
end
|
||||||
@@ -313,7 +313,7 @@ context "Frontend" do
|
|||||||
Precious::App.set(:wiki_options, { :page_file_dir => "foo" })
|
Precious::App.set(:wiki_options, { :page_file_dir => "foo" })
|
||||||
dir = "bardir"
|
dir = "bardir"
|
||||||
name = "#{dir}/baz"
|
name = "#{dir}/baz"
|
||||||
get "/create/foo/#{name}"
|
get "/gollum/create/foo/#{name}"
|
||||||
assert_match(/\/#{dir}/, last_response.body)
|
assert_match(/\/#{dir}/, last_response.body)
|
||||||
assert_no_match(/[^\/]#{dir}/, last_response.body)
|
assert_no_match(/[^\/]#{dir}/, last_response.body)
|
||||||
# reset page_file_dir
|
# reset page_file_dir
|
||||||
@@ -324,7 +324,7 @@ context "Frontend" do
|
|||||||
# post '/edit' fails. post '/edit/' works.
|
# post '/edit' fails. post '/edit/' works.
|
||||||
page = 'not-real-page'
|
page = 'not-real-page'
|
||||||
path = '/'
|
path = '/'
|
||||||
post '/edit/', :content => 'edit_msg',
|
post '/gollum/edit/', :content => 'edit_msg',
|
||||||
:page => page, :path => path, :message => ''
|
:page => page, :path => path, :message => ''
|
||||||
page_e = @wiki.paged(page, path)
|
page_e = @wiki.paged(page, path)
|
||||||
assert_equal nil, page_e
|
assert_equal nil, page_e
|
||||||
@@ -334,7 +334,7 @@ context "Frontend" do
|
|||||||
page = 'c-d-e'
|
page = 'c-d-e'
|
||||||
path = 'a/b/' # path must end with /
|
path = 'a/b/' # path must end with /
|
||||||
|
|
||||||
post '/create', :content => 'create_msg', :page => page,
|
post '/gollum/create', :content => 'create_msg', :page => page,
|
||||||
:path => path, :format => 'markdown', :message => ''
|
:path => path, :format => 'markdown', :message => ''
|
||||||
page_c = @wiki.paged(page, path)
|
page_c = @wiki.paged(page, path)
|
||||||
assert_equal 'create_msg', page_c.raw_data
|
assert_equal 'create_msg', page_c.raw_data
|
||||||
@@ -343,7 +343,7 @@ context "Frontend" do
|
|||||||
@wiki.clear_cache
|
@wiki.clear_cache
|
||||||
|
|
||||||
# post '/edit' fails. post '/edit/' works.
|
# post '/edit' fails. post '/edit/' works.
|
||||||
post '/edit/', :content => 'edit_msg',
|
post '/gollum/edit/', :content => 'edit_msg',
|
||||||
:page => page, :path => path, :message => ''
|
:page => page, :path => path, :message => ''
|
||||||
page_e = @wiki.paged(page, path)
|
page_e = @wiki.paged(page, path)
|
||||||
assert_equal 'edit_msg', page_e.raw_data
|
assert_equal 'edit_msg', page_e.raw_data
|
||||||
@@ -362,7 +362,7 @@ context "Frontend" do
|
|||||||
|
|
||||||
test "guards against creation of existing page" do
|
test "guards against creation of existing page" do
|
||||||
name = "A"
|
name = "A"
|
||||||
post "/create", :content => 'abc', :page => name,
|
post "/gollum/create", :content => 'abc', :page => name,
|
||||||
:format => 'markdown', :message => 'def'
|
:format => 'markdown', :message => 'def'
|
||||||
|
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
@@ -374,12 +374,12 @@ context "Frontend" do
|
|||||||
|
|
||||||
test "delete a page" do
|
test "delete a page" do
|
||||||
name = "deleteme"
|
name = "deleteme"
|
||||||
post "/create", :content => 'abc', :page => name,
|
post "/gollum/create", :content => 'abc', :page => name,
|
||||||
:format => 'markdown', :message => 'foo'
|
:format => 'markdown', :message => 'foo'
|
||||||
page = @wiki.page(name)
|
page = @wiki.page(name)
|
||||||
assert_equal 'abc', page.raw_data
|
assert_equal 'abc', page.raw_data
|
||||||
|
|
||||||
get '/delete/' + name
|
get '/gollum/delete/' + name
|
||||||
|
|
||||||
@wiki.clear_cache
|
@wiki.clear_cache
|
||||||
page = @wiki.page(name)
|
page = @wiki.page(name)
|
||||||
@@ -387,7 +387,7 @@ context "Frontend" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "previews content" do
|
test "previews content" do
|
||||||
post "/preview", :content => 'abc', :format => 'markdown'
|
post "/gollum/preview", :content => 'abc', :format => 'markdown'
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -396,7 +396,7 @@ context "Frontend" do
|
|||||||
@wiki = Gollum::Wiki.new(@path)
|
@wiki = Gollum::Wiki.new(@path)
|
||||||
Precious::App.set(:gollum_path, @path)
|
Precious::App.set(:gollum_path, @path)
|
||||||
Precious::App.set(:wiki_options, {})
|
Precious::App.set(:wiki_options, {})
|
||||||
post "/preview", :content => 'abc', :format => 'markdown'
|
post "/gollum/preview", :content => 'abc', :format => 'markdown'
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -469,7 +469,7 @@ context "Frontend" do
|
|||||||
gollum_author = { :name => 'ghi', :email => 'jkl' }
|
gollum_author = { :name => 'ghi', :email => 'jkl' }
|
||||||
session = { 'gollum.author' => gollum_author }
|
session = { 'gollum.author' => gollum_author }
|
||||||
|
|
||||||
post "/edit/A", { :content => 'abc', :page => 'A', :format => page1.format, :message => 'def' }, { 'rack.session' => session }
|
post "/gollum/edit/A", { :content => 'abc', :page => 'A', :format => page1.format, :message => 'def' }, { 'rack.session' => session }
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
|
|
||||||
@@ -510,21 +510,21 @@ context "Frontend" do
|
|||||||
|
|
||||||
['create', 'edit'].each do |route|
|
['create', 'edit'].each do |route|
|
||||||
['.css', '.js'].each do |ext|
|
['.css', '.js'].each do |ext|
|
||||||
get "/#{route}/custom#{ext}"
|
get "/gollum/#{route}/custom#{ext}"
|
||||||
assert_equal 403, last_response.status, "get /#{route}/custom#{ext} -- #{last_response.inspect}"
|
assert_equal 403, last_response.status, "get /gollum/#{route}/custom#{ext} -- #{last_response.inspect}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
['deleteFile', 'rename', 'edit', 'create'].each do |route|
|
['deleteFile', 'rename', 'edit', 'create'].each do |route|
|
||||||
['.css', '.js'].each do |ext|
|
['.css', '.js'].each do |ext|
|
||||||
post "/#{route}/custom#{ext}"
|
post "/gollum/#{route}/custom#{ext}"
|
||||||
assert_equal 403, last_response.status, "post /#{route}/custom#{ext} -- #{last_response.inspect}"
|
assert_equal 403, last_response.status, "post /gollum/#{route}/custom#{ext} -- #{last_response.inspect}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
['.css', '.js'].each do |ext|
|
['.css', '.js'].each do |ext|
|
||||||
post "/revert/custom#{ext}/02796b1450691f90db5d6dc6a816a4980ce80d07/2f6485c2702c7c8b9b6613672337ffa7d933ddcf"
|
post "/gollum/revert/custom#{ext}/02796b1450691f90db5d6dc6a816a4980ce80d07/2f6485c2702c7c8b9b6613672337ffa7d933ddcf"
|
||||||
assert_equal 403, last_response.status, "post /revert/custom#{ext} -- #{last_response.inspect}"
|
assert_equal 403, last_response.status, "post /gollum/revert/custom#{ext} -- #{last_response.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
Precious::App.set(:wiki_options, { :js => nil })
|
Precious::App.set(:wiki_options, { :js => nil })
|
||||||
@@ -544,15 +544,15 @@ context "Frontend" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "show edit page with header and footer and sidebar of multibyte" do
|
test "show edit page with header and footer and sidebar of multibyte" do
|
||||||
post "/create",
|
post "/gollum/create",
|
||||||
:content => 'りんご',
|
:content => 'りんご',
|
||||||
:page => 'Multibyte', :format => :markdown, :message => 'mesg'
|
:page => 'Multibyte', :format => :markdown, :message => 'mesg'
|
||||||
|
|
||||||
post "/edit/Multibyte",
|
post "/gollum/edit/Multibyte",
|
||||||
:content => 'りんご', :header => 'みかん', :footer => 'バナナ', :sidebar => 'スイカ',
|
:content => 'りんご', :header => 'みかん', :footer => 'バナナ', :sidebar => 'スイカ',
|
||||||
:page => 'Multibyte', :format => :markdown, :message => 'mesg'
|
:page => 'Multibyte', :format => :markdown, :message => 'mesg'
|
||||||
|
|
||||||
get "edit/Multibyte"
|
get "/gollum/edit/Multibyte"
|
||||||
|
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
assert_match /りんご/, last_response.body
|
assert_match /りんご/, last_response.body
|
||||||
@@ -620,7 +620,7 @@ context "Frontend with lotr" do
|
|||||||
#
|
#
|
||||||
|
|
||||||
test "/pages" do
|
test "/pages" do
|
||||||
get "/pages"
|
get "/gollum/pages"
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
|
|
||||||
body = last_response.body
|
body = last_response.body
|
||||||
@@ -633,8 +633,8 @@ context "Frontend with lotr" do
|
|||||||
assert !body.match(/(Zamin).+(roast\-mutton)/m), "/pages should be sorted alphabetically"
|
assert !body.match(/(Zamin).+(roast\-mutton)/m), "/pages should be sorted alphabetically"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "/pages/Mordor/" do
|
test "/gollum/pages/Mordor/" do
|
||||||
get "/pages/Mordor/"
|
get "/gollum/pages/Mordor/"
|
||||||
assert last_response.ok?, "/pages/Mordor/ did not respond ok"
|
assert last_response.ok?, "/pages/Mordor/ did not respond ok"
|
||||||
|
|
||||||
body = last_response.body
|
body = last_response.body
|
||||||
@@ -658,7 +658,7 @@ context "Frontend with lotr" do
|
|||||||
test "create pages within sub-directories using base path" do
|
test "create pages within sub-directories using base path" do
|
||||||
Precious::App.set(:wiki_options, { :base_path => 'wiki' })
|
Precious::App.set(:wiki_options, { :base_path => 'wiki' })
|
||||||
page = 'path'
|
page = 'path'
|
||||||
post "/create", :content => '123', :page => page,
|
post "/gollum/create", :content => '123', :page => page,
|
||||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||||
# should be wiki/Mordor/path
|
# should be wiki/Mordor/path
|
||||||
assert_equal 'http://example.org/Mordor/' + page + '.md', last_response.headers['Location']
|
assert_equal 'http://example.org/Mordor/' + page + '.md', last_response.headers['Location']
|
||||||
@@ -670,7 +670,7 @@ context "Frontend with lotr" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "create pages within sub-directories using page file dir" do
|
test "create pages within sub-directories using page file dir" do
|
||||||
post "/create", :content => 'one two', :page => 'base',
|
post "/gollum/create", :content => 'one two', :page => 'base',
|
||||||
:path => 'wiki/Mordor', :format => 'markdown', :message => 'oooh, scary'
|
:path => 'wiki/Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||||
assert_equal 'http://example.org/wiki/Mordor/base.md', last_response.headers['Location']
|
assert_equal 'http://example.org/wiki/Mordor/base.md', last_response.headers['Location']
|
||||||
get "/wiki/Mordor/base"
|
get "/wiki/Mordor/base"
|
||||||
@@ -680,13 +680,13 @@ context "Frontend with lotr" do
|
|||||||
|
|
||||||
|
|
||||||
test "create pages within sub-directories" do
|
test "create pages within sub-directories" do
|
||||||
post "/create", :content => 'big smelly creatures', :page => 'Orc',
|
post "/gollum/create", :content => 'big smelly creatures', :page => 'Orc',
|
||||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||||
assert_equal 'http://example.org/Mordor/Orc.md', last_response.headers['Location']
|
assert_equal 'http://example.org/Mordor/Orc.md', last_response.headers['Location']
|
||||||
get "/Mordor/Orc"
|
get "/Mordor/Orc"
|
||||||
assert_match /big smelly creatures/, last_response.body
|
assert_match /big smelly creatures/, last_response.body
|
||||||
|
|
||||||
post "/create", :content => 'really big smelly creatures', :page => 'Uruk Hai',
|
post "/gollum/create", :content => 'really big smelly creatures', :page => 'Uruk Hai',
|
||||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, very scary'
|
:path => 'Mordor', :format => 'markdown', :message => 'oooh, very scary'
|
||||||
assert_equal 'http://example.org/Mordor/Uruk%20Hai.md', last_response.headers['Location']
|
assert_equal 'http://example.org/Mordor/Uruk%20Hai.md', last_response.headers['Location']
|
||||||
get "/Mordor/Uruk%20Hai"
|
get "/Mordor/Uruk%20Hai"
|
||||||
@@ -694,12 +694,12 @@ context "Frontend with lotr" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "edit pages within sub-directories" do
|
test "edit pages within sub-directories" do
|
||||||
post "/create", :content => 'big smelly creatures', :page => 'Orc',
|
post "/gollum/create", :content => 'big smelly creatures', :page => 'Orc',
|
||||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||||
|
|
||||||
assert_equal 'http://example.org/Mordor/Orc.md', last_response.headers['Location']
|
assert_equal 'http://example.org/Mordor/Orc.md', last_response.headers['Location']
|
||||||
|
|
||||||
post "/edit/Mordor/Orc", :content => 'not so big smelly creatures',
|
post "/gollum/edit/Mordor/Orc", :content => 'not so big smelly creatures',
|
||||||
:page => 'Orc', :path => 'Mordor', :message => 'minor edit'
|
:page => 'Orc', :path => 'Mordor', :message => 'minor edit'
|
||||||
assert_equal 'http://example.org/Mordor/Orc.md', last_response.headers['Location']
|
assert_equal 'http://example.org/Mordor/Orc.md', last_response.headers['Location']
|
||||||
|
|
||||||
@@ -721,14 +721,14 @@ context "Frontend with lotr" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "existing emoji" do
|
test "existing emoji" do
|
||||||
get "/emoji/heart"
|
get "/gollum/emoji/heart"
|
||||||
assert_equal 200, last_response.status
|
assert_equal 200, last_response.status
|
||||||
assert_equal 'image/png', last_response.headers['Content-Type']
|
assert_equal 'image/png', last_response.headers['Content-Type']
|
||||||
assert_equal [137, 80, 78, 71, 13, 10, 26, 10], last_response.body.each_byte.to_a[0..7]
|
assert_equal [137, 80, 78, 71, 13, 10, 26, 10], last_response.body.each_byte.to_a[0..7]
|
||||||
end
|
end
|
||||||
|
|
||||||
test "missing emoji" do
|
test "missing emoji" do
|
||||||
get "/emoji/oggy_was_here"
|
get "/gollum/emoji/oggy_was_here"
|
||||||
assert_equal 404, last_response.status
|
assert_equal 404, last_response.status
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ context "Precious::Views::LatestChanges" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "displays_latest_changes" do
|
test "displays_latest_changes" do
|
||||||
get('/latest_changes')
|
get('/gollum/latest_changes')
|
||||||
body = last_response.body
|
body = last_response.body
|
||||||
|
|
||||||
assert body.include?('<span class="username">Charles Pence</span>'), "/latest_changes should include the Author Charles Pence"
|
assert body.include?('<span class="username">Charles Pence</span>'), "/latest_changes should include the Author Charles Pence"
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ context "Precious::Views::Pages" do
|
|||||||
@page.instance_variable_set("@base_url", "")
|
@page.instance_variable_set("@base_url", "")
|
||||||
results = [FakePageResult.new("Gondor/Bromir.md"), FakePageResult.new("Hobbit.md"), FakePageResult.new("Home.md"), FakePageResult.new("Mordor/Eye-Of-Sauron.md"), FakePageResult.new("Mordor/todo.md"), FakePageResult.new("Rivendell/Elrond.md"), FakePageResult.new("My-Precious.md"), FakePageResult.new("Zamin.md"), FakePageResult.new("Samwise-Gamgee.md"), FakePageResult.new("roast-mutton.md"), FakePageResult.new("Bilbo-Baggins.md")]
|
results = [FakePageResult.new("Gondor/Bromir.md"), FakePageResult.new("Hobbit.md"), FakePageResult.new("Home.md"), FakePageResult.new("Mordor/Eye-Of-Sauron.md"), FakePageResult.new("Mordor/todo.md"), FakePageResult.new("Rivendell/Elrond.md"), FakePageResult.new("My-Precious.md"), FakePageResult.new("Zamin.md"), FakePageResult.new("Samwise-Gamgee.md"), FakePageResult.new("roast-mutton.md"), FakePageResult.new("Bilbo-Baggins.md")]
|
||||||
@page.instance_variable_set("@results", results)
|
@page.instance_variable_set("@results", results)
|
||||||
assert_equal %{<li><a href="/pages/Gondor/" class="folder">Gondor</a></li>\n<li><a href="/pages/Mordor/" class="folder">Mordor</a></li>\n<li><a href="/pages/Rivendell/" class="folder">Rivendell</a></li>\n<li><a href="/Bilbo-Baggins" class="page">Bilbo Baggins</a></li>\n<li><a href="/Hobbit" class="page">Hobbit</a></li>\n<li><a href="/Home" class="page">Home</a></li>\n<li><a href="/My-Precious" class="page">My Precious</a></li>\n<li><a href="/roast-mutton" class="page">roast mutton</a></li>\n<li><a href="/Samwise-Gamgee" class="page">Samwise Gamgee</a></li>\n<li><a href="/Zamin" class="page">Zamin</a></li>}, @page.files_folders
|
assert_equal %{<li><a href="/gollum/pages/Gondor/" class="folder">Gondor</a></li>\n<li><a href="/gollum/pages/Mordor/" class="folder">Mordor</a></li>\n<li><a href="/gollum/pages/Rivendell/" class="folder">Rivendell</a></li>\n<li><a href="/Bilbo-Baggins" class="page">Bilbo Baggins</a></li>\n<li><a href="/Hobbit" class="page">Hobbit</a></li>\n<li><a href="/Home" class="page">Home</a></li>\n<li><a href="/My-Precious" class="page">My Precious</a></li>\n<li><a href="/roast-mutton" class="page">roast mutton</a></li>\n<li><a href="/Samwise-Gamgee" class="page">Samwise Gamgee</a></li>\n<li><a href="/Zamin" class="page">Zamin</a></li>}, @page.files_folders
|
||||||
end
|
end
|
||||||
|
|
||||||
test "files_folders from subdir" do
|
test "files_folders from subdir" do
|
||||||
@@ -54,7 +54,7 @@ context "Precious::Views::Pages" do
|
|||||||
@page.instance_variable_set("@base_url", "")
|
@page.instance_variable_set("@base_url", "")
|
||||||
results = [FakePageResult.new("Mordor/Eye-Of-Sauron.md"), FakeFileResult.new("Mordor/Aragorn.pdf"), FakePageResult.new("Mordor/Orc/Saruman.md"), FakeFileResult.new("Mordor/.gitkeep")]
|
results = [FakePageResult.new("Mordor/Eye-Of-Sauron.md"), FakeFileResult.new("Mordor/Aragorn.pdf"), FakePageResult.new("Mordor/Orc/Saruman.md"), FakeFileResult.new("Mordor/.gitkeep")]
|
||||||
@page.instance_variable_set("@results", results)
|
@page.instance_variable_set("@results", results)
|
||||||
assert_equal %{<li><a href="/pages/Mordor/Orc/" class="folder">Orc</a></li>\n<li><a href="/Mordor/Aragorn.pdf" class="file">Aragorn.pdf</a></li>\n<li><a href="/Mordor/Eye-Of-Sauron" class="page">Eye Of Sauron</a></li>}, @page.files_folders
|
assert_equal %{<li><a href="/gollum/pages/Mordor/Orc/" class="folder">Orc</a></li>\n<li><a href="/Mordor/Aragorn.pdf" class="file">Aragorn.pdf</a></li>\n<li><a href="/Mordor/Eye-Of-Sauron" class="page">Eye Of Sauron</a></li>}, @page.files_folders
|
||||||
end
|
end
|
||||||
|
|
||||||
test "base url" do
|
test "base url" do
|
||||||
@@ -63,6 +63,6 @@ context "Precious::Views::Pages" do
|
|||||||
@page.instance_variable_set("@base_url", "/wiki")
|
@page.instance_variable_set("@base_url", "/wiki")
|
||||||
results = [FakePageResult.new("Mordor/Eye-Of-Sauron.md"), FakeFileResult.new("Mordor/Aragorn.pdf"), FakePageResult.new("Mordor/Orc/Saruman.md"), FakePageResult.new("Mordor/.gitkeep")]
|
results = [FakePageResult.new("Mordor/Eye-Of-Sauron.md"), FakeFileResult.new("Mordor/Aragorn.pdf"), FakePageResult.new("Mordor/Orc/Saruman.md"), FakePageResult.new("Mordor/.gitkeep")]
|
||||||
@page.instance_variable_set("@results", results)
|
@page.instance_variable_set("@results", results)
|
||||||
assert_equal %{<li><a href="/wiki/pages/Mordor/Orc/" class="folder">Orc</a></li>\n<li><a href="/wiki/Mordor/Aragorn.pdf" class="file">Aragorn.pdf</a></li>\n<li><a href="/wiki/Mordor/Eye-Of-Sauron" class="page">Eye Of Sauron</a></li>}, @page.files_folders
|
assert_equal %{<li><a href="/wiki/gollum/pages/Mordor/Orc/" class="folder">Orc</a></li>\n<li><a href="/wiki/Mordor/Aragorn.pdf" class="file">Aragorn.pdf</a></li>\n<li><a href="/wiki/Mordor/Eye-Of-Sauron" class="page">Eye Of Sauron</a></li>}, @page.files_folders
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ context "Frontend Unicode support" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "creates korean page which contains korean content" do
|
test "creates korean page which contains korean content" do
|
||||||
post "/create", :content => '한글 text', :page => "k",
|
post "/gollum/create", :content => '한글 text', :page => "k",
|
||||||
:format => 'markdown', :message => 'def'
|
:format => 'markdown', :message => 'def'
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
@@ -48,7 +48,7 @@ context "Frontend Unicode support" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "heavy use 1" do
|
test "heavy use 1" do
|
||||||
post "/create", :content => '한글 text', :page => "PG",
|
post "/gollum/create", :content => '한글 text', :page => "PG",
|
||||||
:format => 'markdown', :message => 'def'
|
:format => 'markdown', :message => 'def'
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
@@ -57,7 +57,7 @@ context "Frontend Unicode support" do
|
|||||||
page = @wiki.page('PG')
|
page = @wiki.page('PG')
|
||||||
assert_equal '다른 text', utf8(page.raw_data)
|
assert_equal '다른 text', utf8(page.raw_data)
|
||||||
|
|
||||||
post '/edit/PG', :page => 'PG', :content => '바뀐 text', :message => 'ghi'
|
post '/gollum/edit/PG', :page => 'PG', :content => '바뀐 text', :message => 'ghi'
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ context "Frontend Unicode support" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "heavy use 2" do
|
test "heavy use 2" do
|
||||||
post "/create", :content => '한글 text', :page => "k",
|
post "/gollum/create", :content => '한글 text', :page => "k",
|
||||||
:format => 'markdown', :message => 'def'
|
:format => 'markdown', :message => 'def'
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
@@ -78,7 +78,7 @@ context "Frontend Unicode support" do
|
|||||||
page = @wiki.page('k')
|
page = @wiki.page('k')
|
||||||
assert_equal '다른 text', utf8(page.raw_data)
|
assert_equal '다른 text', utf8(page.raw_data)
|
||||||
|
|
||||||
post '/edit/' + CGI.escape('한글'), :page => 'k', :content => '바뀐 text',
|
post '/gollum/edit/' + CGI.escape('한글'), :page => 'k', :content => '바뀐 text',
|
||||||
:format => 'markdown', :message => 'ghi'
|
:format => 'markdown', :message => 'ghi'
|
||||||
follow_redirect!
|
follow_redirect!
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
|
|||||||
Reference in New Issue
Block a user