Merge branch 'master' into base-url

Conflicts:
	lib/gollum/frontend/public/gollum/css/_styles.css
	lib/gollum/frontend/public/gollum/javascript/gollum.js
	lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js
	lib/gollum/frontend/templates/file_view.mustache
	lib/gollum/frontend/templates/layout.mustache
	lib/gollum/frontend/templates/page.mustache
This commit is contained in:
Sunny Ripert
2012-07-25 10:00:52 +02:00
119 changed files with 1324 additions and 11613 deletions
+1 -1
View File
@@ -526,7 +526,7 @@ your changes merged back into core is as follows:
$ gem push gollum-X.Y.Z.gem
## BUILDING THE GEM FROM MASTER
$ gem uninstall -aix gollum
$ git clone https://github.com/github/gollum.git
$ cd gollum
gollum$ rake build
+9 -2
View File
@@ -48,11 +48,15 @@ opts = OptionParser.new do |opts|
opts.on("--page-file-dir [PATH]", "Specify the sub directory for all page files (default: repository root).") do |path|
wiki_options[:page_file_dir] = path
end
opts.on("--base-path [PATH]", "Specify the base path.") do |path|
wiki_options[:base_path] = path
end
opts.on("--gollum-path [PATH]", "Specify the gollum path.") do |path|
wiki_options[:gollum_path] = path
end
opts.on("--ref [REF]", "Specify the repository ref to use (default: master).") do |ref|
wiki_options[:ref] = ref
end
@@ -75,7 +79,10 @@ rescue OptionParser::InvalidOption
exit
end
gollum_path = ARGV[0] || Dir.pwd
# --gollum-path wins over ARGV[0]
gollum_path = wiki_options[:gollum_path] ?
wiki_options[:gollum_path] :
ARGV[0] || Dir.pwd
if options['irb']
require 'irb'
+1
View File
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
s.add_dependency('sanitize', "~> 2.0.0")
s.add_dependency('nokogiri', "~> 1.4")
s.add_dependency('useragent', "~> 0.4.9")
s.add_dependency('stringex', "~> 1.4.0")
s.add_development_dependency('RedCloth')
s.add_development_dependency('mocha')
+27 -42
View File
@@ -15,19 +15,19 @@ module Gollum
def new_page page
name = page.name
%Q( <li class="file"><a href="#{name}">#{name}</a></li>\n)
url = page.filename_stripped
%Q( <li class="file"><a href="#{url}">#{name}</a></li>\n)
end
def new_folder page
new_sub_folder ::File.dirname(page.path), page.name
def new_folder folder_path
new_sub_folder folder_path
end
def new_sub_folder path, name
def new_sub_folder path
<<-HTML
<li>
<label>#{path}</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="#{name}">#{name}</a></li>
HTML
end
@@ -65,11 +65,12 @@ module Gollum
if (count - folder_start == 1)
page = @pages[ folder_start ]
name = page.name
url = page.filename_stripped
html += <<-HTML
<li>
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" checked />
<ol>
<li class="file"><a href="#{name}">#{name}</a></li>
<li class="file"><a href="#{url}">#{name}</a></li>
</ol>
</li>
HTML
@@ -99,54 +100,38 @@ module Gollum
end
end
# Process first folder
page = @pages[ sorted_folders[ 0 ][1] ]
html += new_folder page
last_folder = ::File.dirname page.path # define last_folder
# keep track of folder depth, 0 = at root.
depth = 0
cwd_array = []
changed = false
# process rest of folders
1.upto(sorted_folders.size - 1) do | index |
page = @pages[ sorted_folders[ index ][1] ]
(0...sorted_folders.size).each do | index |
page = @pages[ sorted_folders[ index ][ 1 ] ]
path = page.path
folder = ::File.dirname path
if last_folder == folder
# same folder
html += new_page page
elsif folder.include?('/')
# check if we're going up or down a depth level
if last_folder.scan('/').size > folder.scan('/').size
# end tag for 1 subfolder & 1 parent folder
# so emit 2 end tags
2.times { html += end_folder; }
depth -= 1
else
depth += 1
tmp_array = folder.split '/'
(0...tmp_array.size).each do | index |
if cwd_array[ index ].nil? || changed
html += new_sub_folder tmp_array[ index ]
next
end
# subfolder
html += new_sub_folder ::File.dirname(page.path).split('/').last, page.name
else
# depth+1 because we need an additional end_folder
(depth+1).times { html += end_folder; }
depth = 0
# New root folder
html += new_folder page
if cwd_array[ index ] != tmp_array[ index ]
changed = true
(cwd_array.size - index).times do
html += end_folder
end
html += new_sub_folder tmp_array[ index ]
end
end
last_folder = folder
html += new_page page
cwd_array = tmp_array
changed = false
end
# Process last folder's ending tags.
(depth+1).times {
depth.times { html += end_folder; }
depth = 0
}
# return the completed html
enclose_tree html
end # end render_files
+51 -19
View File
@@ -3,6 +3,7 @@ require 'sinatra'
require 'gollum'
require 'mustache/sinatra'
require 'useragent'
require 'stringex'
require 'gollum/frontend/views/layout'
require 'gollum/frontend/views/editable'
@@ -11,6 +12,17 @@ require 'gollum/frontend/views/has_page'
require File.expand_path '../uri_encode_component', __FILE__
require File.expand_path '../helpers', __FILE__
# Fix to_url
class String
alias :upstream_to_url :to_url
# _Header => header which causes errors
def to_url
return nil if self.nil?
return self if ['_Header', '_Footer', '_Sidebar'].include? self
upstream_to_url
end
end
# Run the frontend, based on Sinatra
#
# There are a number of wiki options that can be set for the frontend
@@ -30,15 +42,17 @@ module Precious
dir = File.dirname(File.expand_path(__FILE__))
# Detect unsupported browsers.
@@supported_browsers = ['Firefox', 'Chrome', 'Safari']
Browser = Struct.new(:browser, :version)
@@ie9 = Browser.new('Internet Explorer', '9.0')
@@min_ua = [
Browser.new('Internet Explorer', '10.0'),
Browser.new('Chrome', '7.0'),
Browser.new('Firefox', '4.0'),
]
def supported_useragent?(user_agent)
ua = UserAgent.parse(user_agent)
return true if ua >= @@ie9
@@supported_browsers.include? ua.browser
@@min_ua.detect {|min| ua >= min }
end
# We want to serve public assets for now
@@ -102,7 +116,8 @@ module Precious
else
@page = page
@page.version = wiki.repo.log(wiki.ref, @page.path).first
@content = page.raw_data
raw_data = page.raw_data
@content = raw_data.respond_to?(:force_encoding) ? raw_data.force_encoding('UTF-8') : raw_data
mustache :edit
end
else
@@ -111,11 +126,12 @@ module Precious
end
post '/edit/*' do
path = sanitize_empty_params(params[:path])
path = extract_path(sanitize_empty_params(params[:path]))
wiki_options = settings.wiki_options.merge({ :page_file_dir => path })
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
page = wiki.page(CGI.unescape(params[:page]))
name = params[:rename] || page.name
rename = params[:rename].to_url if params[:rename]
name = rename || page.name
committer = Gollum::Committer.new(wiki, commit_message)
commit = {:committer => committer}
@@ -125,23 +141,38 @@ module Precious
update_wiki_page(wiki, page.sidebar, params[:sidebar], commit) if params[:sidebar]
committer.commit
page = wiki.page(params[:rename]) if params[:rename]
page = wiki.page(rename) if rename
redirect to("/#{page.escaped_url_path}")
end
get '/delete/*' do
@path = extract_path(params[:splat].first)
@name = extract_name(params[:splat].first)
wiki_options = settings.wiki_options.merge({ :page_file_dir => @path })
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
@page = wiki.page(@name)
wiki.delete_page(@page, { :message => "Destroyed #{@name} (#{@page.format})" })
redirect '/'
end
get '/create/*' do
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
@name = params[:splat].first
if wiki.page(@name)
redirect "/#{CGI.escape(@name)}"
@path = extract_path(params[:splat].first)
@name = extract_name(params[:splat].first).to_url
wiki_options = settings.wiki_options.merge({ :page_file_dir => @path })
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
page = wiki.page(@name)
if page
redirect "/#{page.escaped_url_path}"
else
mustache :create
end
end
post '/create' do
name = params[:page]
name = params[:page].to_url
path = sanitize_empty_params(params[:path])
format = params[:format].intern
@@ -314,17 +345,18 @@ module Precious
content_type file.mime_type
file.raw_data
else
redirect "/create/#{CGI.escape(name)}"
page_path = [path, name].compact.join('/')
redirect "/create/#{CGI.escape(page_path).gsub('%2F','/')}"
end
end
def update_wiki_page(wiki, page, content, commit_message, name = nil, format = nil)
def update_wiki_page(wiki, page, content, commit, name = nil, format = nil)
return if !page ||
((!content || page.raw_data == content) && page.format == format)
name ||= page.name
format = (format || page.format).to_sym
content ||= page.raw_data
wiki.update_page(page, name, format, content.to_s, commit_message)
wiki.update_page(page, name, format, content.to_s, commit)
end
def commit_message
+1
View File
@@ -2,6 +2,7 @@ module Precious
module Helpers
# Extract the path string that Gollum::Wiki expects
def extract_path(file_path)
return nil if file_path.nil?
last_slash = file_path.rindex("/")
if last_slash
file_path[0, last_slash]
@@ -1,6 +1,6 @@
/* Just some base styles not needed for example to function */
*, html { font-family: Verdana, Arial, Helvetica, sans-serif; }
*, html {
font-family: Verdana, Arial, Helvetica, sans-serif;
}
#results a:hover {
background-color: #4c4c4c;
@@ -13,9 +13,8 @@
}
#home_button .minibutton {
/* controls size of home btn */
font-size: 1em;
text-align: center;
font-size: 1em;
text-align: center;
}
#results {
@@ -24,87 +23,99 @@ text-align: center;
left: 10px;
}
body, form, ul, li, p, h1, h2, h3, h4, h5
{
margin: 0;
padding: 0;
body, form, ul, li, p, h1, h2, h3, h4, h5 {
margin: 0;
padding: 0;
}
body { background-color: #606061; color: #ffffff; margin: 0; }
img { border: none; }
p
{
font-size: 1em;
margin: 0 0 1em 0;
body {
background-color: #606061;
color: #ffffff;
margin: 0;
}
img {
border: none;
}
p {
font-size: 1em;
margin: 0 0 1em 0;
}
html { font-size: 100%; /* IE hack */ }
body { font-size: 1em; /* Sets base font size to 16px */ }
table { font-size: 100%; /* IE hack */ }
input, select, textarea, th, td { font-size: 1em; }
/* Prevent wrapping on large file names. */
li.file {
white-space: nowrap;
}
/* CSS Tree menu styles */
ol.tree
{
padding: 0 0 0 30px;
width: 300px;
padding: 0 0 0 30px;
width: 300px;
}
li
{
position: relative;
margin-left: -15px;
list-style: none;
}
li.file
{
margin-left: -1px !important;
li
{
position: relative;
margin-left: -15px;
list-style: none;
}
li.file
{
margin-left: -1px !important;
height: 1.5em;
}
li.file a
{
background: url(../images/fileview/document.png) 0 0 no-repeat;
color: #fff;
padding-left: 21px;
text-decoration: none;
display: block;
}
li.file a[href *= '.pdf'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href *= '.html'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href $= '.css'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href $= '.js'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li input
{
position: absolute;
left: 0;
margin-left: 0;
opacity: 0;
z-index: 2;
cursor: pointer;
height: 1em;
width: 1em;
top: 0;
}
li input + ol
{
background: url(../images/fileview/toggle-small-expand.png) 40px 0 no-repeat;
margin: -1.188em 0 0 -44px; /* 15px */
height: 1.5em;
}
li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; }
li label
{
background: url(../images/fileview/folder-horizontal.png) 15px 1px no-repeat;
cursor: pointer;
display: block;
padding-left: 37px;
}
}
li.file a
{
background: url(../images/fileview/document.png) 0 0 no-repeat;
color: #fff;
padding-left: 21px;
text-decoration: none;
display: block;
}
li.file a[href *= '.pdf'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href *= '.html'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href $= '.css'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href $= '.js'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li input
{
position: absolute;
left: 0;
margin-left: 0;
opacity: 0;
z-index: 2;
cursor: pointer;
height: 1em;
width: 1em;
top: 0;
}
li input + ol
{
background: url(../images/fileview/toggle-small-expand.png) 40px 0 no-repeat;
margin: -1.188em 0 0 -44px; /* 15px */
height: 1.5em;
}
li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; }
li label
{
background: url(../images/fileview/folder-horizontal.png) 15px 1px no-repeat;
cursor: pointer;
display: block;
padding-left: 37px;
}
li input:checked + ol
{
background: url(../images/fileview/toggle-small.png) 40px 5px no-repeat;
margin: -1.5em 0 0 -44px; /* 20px */
padding: 1.563em 0 0 80px;
height: auto;
}
li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */}
li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ }
li input:checked + ol
{
background: url(../images/fileview/toggle-small.png) 40px 5px no-repeat;
margin: -1.5em 0 0 -44px; /* 20px */
padding: 1.563em 0 0 80px;
height: auto;
}
li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */}
li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ }
@@ -226,6 +226,8 @@ a.absent {
}
.markdown-body table {
padding: 0;
border-collapse: collapse;
border-spacing: 0;
}
.markdown-body table tr {
border-top: 1px solid #ccc;
@@ -24,7 +24,6 @@
* You don't need to do anything. Just run this on DOM ready.
*/
$.GollumEditor = function( IncomingOptions ) {
ActiveOptions = $.extend( DefaultOptions, IncomingOptions );
debug('GollumEditor loading');
@@ -96,11 +95,8 @@
$('#gollum-editor-help').hide();
$('#gollum-editor-help').removeClass('jaws');
}
}
// EditorHas.functionBar
}
// EditorHas.baseEditorMarkup
} // EditorHas.functionBar
} // EditorHas.baseEditorMarkup
};
@@ -199,6 +195,18 @@
if(LanguageDefinition.getHookFunctionFor("activate")) {
LanguageDefinition.getHookFunctionFor("activate")();
}
function hotkey( cmd ) {
var def = LanguageDefinition.getDefinitionFor( cmd );
if ( typeof def == 'object' ) {
FunctionBar.executeAction( def );
}
// Prevent bubbling of hotkey.
return false;
}
Mousetrap.bind(['command+b', 'ctrl+b'], function(){ hotkey('function-bold'); });
Mousetrap.bind(['command+i', 'ctrl+i'], function(){ hotkey('function-italic'); });
} );
} else {
LanguageDefinition._ACTIVE_LANG = name;
@@ -32,7 +32,7 @@ var MarkDown = {
},
'function-code' : {
search: /(^[\n]+)([\n\s]*)/g,
search: /([^\n]+)([\n\s]*)/g,
replace: "`$1`$2"
},
@@ -44,11 +44,22 @@ var MarkDown = {
search: /(.+)([\n]?)/g,
replace: "* $1$2"
},
/* This looks silly but is completely valid Markdown */
/* based on rdoc.js */
'function-ol' : {
search: /(.+)([\n]?)/g,
replace: "1. $1$2"
exec: function( txt, selText, $field ) {
var count = 1;
// split into lines
var repText = '';
var lines = selText.split("\n");
var hasContent = /[\w]+/;
for ( var i = 0; i < lines.length; i++ ) {
if ( hasContent.test(lines[i]) ) {
repText += (i + 1).toString() + '. ' +
lines[i] + "\n";
}
}
$.GollumEditor.replaceSelection( repText );
}
},
'function-blockquote' : {
@@ -1,5 +1,21 @@
// ua
$(document).ready(function() {
$('#delete-link').click( function(e) {
var ok = confirm($(this).data('confirm'));
if ( ok ) {
var href = window.location.href;
var index = href.lastIndexOf('/');
// /home
var page = href.substr(index);
// http://localhost:4567/
var host = href.substr(0, index+1);
var loc = host + 'delete' + page;
window.location = loc;
}
// Don't navigate on cancel.
e.preventDefault();
} );
var nodeSelector = {
node1: null,
node2: null,
@@ -97,31 +113,71 @@ $(document).ready(function() {
}
}
if ($('#minibutton-rename-page').length) {
$('#minibutton-rename-page').removeClass('jaws');
$('#minibutton-rename-page').click(function(e) {
e.preventDefault();
var path = window.location.pathname;
var oldName = path.substring(path.lastIndexOf('/')+1);
$.GollumDialog.init({
title: 'Rename Page',
fields: [
{
id: 'name',
name: 'Rename to',
type: 'text',
defaultValue: oldName || ''
}
],
OK: function( res ) {
var name = 'Rename Page';
if ( res['name'] ) {
name = res['name'];
}
var msg = 'Renamed ' + oldName + ' to ' + name;
jQuery.ajax( {
type: 'POST',
url: '/edit/' + oldName,
// omit path: pathName until https://github.com/github/gollum/issues/446 is fixed.
data: { rename: name, page: oldName, message: msg },
success: function() {
window.location = '/' + encodeURIComponent(name);
}
});
}
});
});
}
if ($('#minibutton-new-page').length) {
$('#minibutton-new-page').removeClass('jaws');
$('#minibutton-new-page').click(function(e) {
e.preventDefault();
var path = $(this).data('path');
if (path) {
path = path + '/';
}
$.GollumDialog.init({
title: 'Create New Page',
fields: [
{
id: 'name',
name: 'Page Name',
type: 'text'
type: 'text',
defaultValue: path || ''
}
],
OK: function( res ) {
var name = 'New Page';
if ( res['name'] ) {
var name = res['name'];
name = res['name'];
}
var url = baseUrl;
var path = $('#minibutton-new-page').data('path');
if (path) {
url += '/' + encodeURIComponent(path)
}
window.location = url + '/' + encodeURIComponent(name);
window.location = baseUrl + '/' + encodeURIComponent(name);
}
});
});
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,8 @@
/* mousetrap v1.1.2 craig.is/killing/mice */
window.Mousetrap=function(){function o(a,c,b){if(a.addEventListener)return a.addEventListener(c,b,!1);a.attachEvent("on"+c,b)}function u(a){return"keypress"==a.type?String.fromCharCode(a.which):h[a.which]?h[a.which]:v[a.which]?v[a.which]:String.fromCharCode(a.which).toLowerCase()}function p(a){var a=a||{},c=!1,b;for(b in l)a[b]?c=!0:l[b]=0;c||(n=!1)}function w(a,c,b,d,C){var g,e,f=[];if(!j[a])return[];"keyup"==b&&q(a)&&(c=[a]);for(g=0;g<j[a].length;++g)if(e=j[a][g],!(e.seq&&l[e.seq]!=e.level)&&b==
e.action&&("keypress"==b||c.sort().join(",")===e.modifiers.sort().join(",")))d&&e.combo==C&&j[a].splice(g,1),f.push(e);return f}function r(a,c){!1===a(c)&&(c.preventDefault&&c.preventDefault(),c.stopPropagation&&c.stopPropagation(),c.returnValue=!1,c.cancelBubble=!0)}function s(a){a.which="number"==typeof a.which?a.which:a.keyCode;var c=u(a);if(c)if("keyup"==a.type&&t==c)t=!1;else{var b=a.target||a.srcElement,d=b.tagName;if(!(-1<(" "+b.className+" ").indexOf(" mousetrap ")?0:"INPUT"==d||"SELECT"==
d||"TEXTAREA"==d||b.contentEditable&&"true"==b.contentEditable)){b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");for(var b=w(c,b,a.type),f={},g=!1,d=0;d<b.length;++d)b[d].seq?(g=!0,f[b[d].seq]=1,r(b[d].callback,a)):!g&&!n&&r(b[d].callback,a);a.type==n&&!q(c)&&p(f)}}}function q(a){return"shift"==a||"ctrl"==a||"alt"==a||"meta"==a}function x(a,c,b){if(!b){if(!k){k={};for(var d in h)95<d&&112>d||h.hasOwnProperty(d)&&(k[h[d]]=d)}b=k[a]?"keydown":
"keypress"}"keypress"==b&&c.length&&(b="keydown");return b}function y(a,c,b,d,f){var a=a.replace(/\s+/g," "),g=a.split(" "),e,h,i=[];if(1<g.length){var k=a,m=b;l[k]=0;m||(m=x(g[0],[]));a=function(){n=m;++l[k];clearTimeout(z);z=setTimeout(p,1E3)};b=function(a){r(c,a);"keyup"!==m&&(t=u(a));setTimeout(p,10)};for(d=0;d<g.length;++d)y(g[d],d<g.length-1?a:b,m,k,d)}else{h="+"===a?["+"]:a.split("+");for(g=0;g<h.length;++g)e=h[g],A[e]&&(e=A[e]),b&&("keypress"!=b&&B[e])&&(e=B[e],i.push("shift")),q(e)&&i.push(e);
b=x(e,i,b);j[e]||(j[e]=[]);w(e,i,b,!d,a);j[e][d?"unshift":"push"]({callback:c,modifiers:i,action:b,seq:d,level:f,combo:a})}}for(var h={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",224:"meta"},v={106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},B=
{"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},A={option:"alt",command:"meta","return":"enter",escape:"esc"},k,j={},i={},l={},z,t=!1,n=!1,f=1;20>f;++f)h[111+f]="f"+f;for(f=0;9>=f;++f)h[f+96]=f;o(document,"keypress",s);o(document,"keydown",s);o(document,"keyup",s);return{bind:function(a,c,b){for(var d=a instanceof Array?a:[a],f=0;f<d.length;++f)y(d[f],c,b);i[a+":"+b]=c},unbind:function(a,c){i[a+
":"+c]&&(delete i[a+":"+c],this.bind(a,function(){},c))},trigger:function(a,c){i[a+":"+c]()},reset:function(){j={};i={}}}}();
@@ -29,6 +29,15 @@ body {
font-size: 16px;
}
/*
Must set ace-line to preserve whitespace in empty lines.
Ace editor sets the height inline. The static highlight ext does not.
<div class="ace_line" style="height:15px"></div>
*/
#previewframe #contentframe .ace-github .ace_editor.ace_scroller.ace_text-layer .ace_line {
height: 15px;
}
/* Set comment to have a higher z-index
so editor doesn't display in the background. */
@@ -59,7 +68,7 @@ so editor doesn't display in the background. */
position: fixed;
background: #666;
top: 0;
height: 31px;
height: 30px;
right: 20px;
width: 80px;
vertical-align: middle;
@@ -2,41 +2,45 @@
<html>
<head>
<title>Live Preview</title>
<link rel="stylesheet" type="text/css" href="../css/template.css" />
<link rel="stylesheet" type="text/css" href="css/custom.css" />
<link rel='stylesheet' type='text/css' href='../css/template.css' />
<link rel='stylesheet' type='text/css' href='css/custom.css' />
</head>
<body>
<div id="editor"></div>
<div id="previewframe"><div id="contentframe" class="markdown-body"></div></div>
<div id='editor'></div>
<div id='previewframe'><div id='contentframe' class='markdown-body'></div></div>
<!-- tool panel from notepage.es. save & savecomment icons from Retina Display Icon Set. -->
<div id="toolpanel" class="toolpanel edit" style="width: 500px; right: 0px; visibility: hidden;">
<a id="save" class="edit"><img src="images/save_24.png" alt="Save" title="Save"></a>
<a id="savecomment" class="edit"><img src="images/savecomment_24.png" alt="Save with comment" title="Save with comment"></a>
<a id="toggle" class="edit" href="javascript:void(0)" onclick="jsm.toggleLeftRight();"><img src="images/lr_24.png" alt="Toggle left to right" title="Toggle left to right"></a>
<div id='toolpanel' class='toolpanel edit' style='width: 500px; right: 0px; visibility: hidden;'>
<a id='save' class='edit'><img src='images/save_24.png' alt='Save' title='Save'></a>
<a id='savecomment' class='edit'><img src='images/savecomment_24.png' alt='Save with comment' title='Save with comment'></a>
<a id='toggle' class='edit' href='javascript:void(0)' onclick='jsm.toggleLeftRight();'><img src='images/lr_24.png' alt='Toggle left to right' title='Toggle left to right'></a>
</div>
<div id="commenttoolpanel" class="toolpanel edit" style="width: 500px; right: 0px; ">
<a id="savecommentconfirm" class="edit"><img src="images/savecomment_24.png" alt="Confirm save with comment" title="Confirm save with comment"></a>
<a id="commentcancel" class="edit"><img src="images/cancel_24.png" alt="Cancel save with comment" title="Cancel save with comment"></a>
<div id='commenttoolpanel' class='toolpanel edit' style='width: 500px; right: 0px; '>
<a id='savecommentconfirm' class='edit'><img src='images/savecomment_24.png' alt='Confirm save with comment' title='Confirm save with comment'></a>
<a id='commentcancel' class='edit'><img src='images/cancel_24.png' alt='Cancel save with comment' title='Cancel save with comment'></a>
</div>
<div id="comment"></div>
<div id="darkness"></div>
<div id='comment'></div>
<div id='darkness'></div>
<script type="text/javascript">
<script>
var require = {
paths: {
ace: "js/ace/lib/ace"
ace: 'js/ace/lib/ace'
}
};
</script>
<script src="js/requirejs/require.js" type="text/javascript" charset="utf-8"></script>
<script src="js/pagedown/Markdown.Converter.js" type="text/javascript" charset="utf-8"></script>
<script src="js/pagedown/Markdown.Sanitizer.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery/jquery-1.7.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/debounce/jquery.ba-throttle-debounce.js" type="text/javascript" charset="utf-8"></script>
<script src="js/livepreview/livepreview.js" type="text/javascript" charset="utf-8"></script>
<script src="https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript" charset="utf-8"></script>
<script src='js/requirejs.min.js'></script>
<script src='../javascript/jquery-1.7.2.min.js'></script>
<script src='js/jquery.ba-throttle-debounce.min.js'></script>
<script src='js/sundown.js'></script>
<script src='js/md_sundown.js'></script>
<script src='js/livepreview.js'></script>
<script>(function(d,j){
j = d.createElement('script');
j.src = 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
(d.head || d.getElementsByTagName('head')[0]).appendChild(j);
}(document));
</script>
</body>
</html>
@@ -92,7 +92,7 @@ exports.multiSelectCommands = [{
bindKey: "esc",
exec: function(editor) { editor.exitMultiSelectMode(); },
readonly: true,
isAvailable: function(editor) {return editor.inMultiSelectMode}
isAvailable: function(editor) {return editor && editor.inMultiSelectMode}
}];
var HashHandler = require("../keyboard/hash_handler").HashHandler;
@@ -97,10 +97,9 @@ exports.init = function() {
}
}
var m = src.match(/^(?:(.*\/)ace\.js)(?:\?|$)/);
if (m) {
scriptUrl = m[1] || m[2];
}
var m = src.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);
if (m)
scriptUrl = m[1];
}
if (scriptUrl) {
@@ -50,9 +50,11 @@
.ace_gutter-cell.ace_info {
background-image: url("data:image/gif;base64,R0lGODlhEAAQAMQAAAAAAEFBQVJSUl5eXmRkZGtra39/f4WFhYmJiZGRkaampry8vMPDw8zMzNXV1dzc3OTk5Orq6vDw8P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABQALAAAAAAQABAAAAUuICWOZGmeaBml5XGwFCQSBGyXRSAwtqQIiRuiwIM5BoYVbEFIyGCQoeJGrVptIQA7");
background-repeat: no-repeat;
background-position: 2px center;
}
.ace_dark .ace_gutter-cell.ace_info {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpGRTk5MTVGREIxNDkxMUUxOTc5Q0FFREQyMTNGMjBFQyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpGRTk5MTVGRUIxNDkxMUUxOTc5Q0FFREQyMTNGMjBFQyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkZFOTkxNUZCQjE0OTExRTE5NzlDQUVERDIxM0YyMEVDIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkZFOTkxNUZDQjE0OTExRTE5NzlDQUVERDIxM0YyMEVDIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+SIDkjAAAAJ1JREFUeNpi/P//PwMlgImBQkB7A6qrq/+DMC55FkIGKCoq4pVnpFkgTp069f/+/fv/r1u37r+tre1/kg0A+ptn9uzZYLaRkRHpLvjw4cNXWVlZhufPnzOcO3eOdAO0tbVPAjHDmzdvGA4fPsxIsgGSkpJmv379Ynj37h2DjIyMCMkG3LhxQ/T27dsMampqDHZ2dq/pH41DxwCAAAMAFdc68dUsFZgAAAAASUVORK5CYII=");
}
.ace_editor .ace_sb {
position: absolute;
@@ -246,9 +248,11 @@
background-image: url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAe%8A%B1%0D%000%0C%C2%F2%2CK%96%BC%D0%8F9%81%88H%E9%D0%0E%96%C0%10%92%3E%02%80%5E%82%E4%A9*-%EEsw%C8%CC%11%EE%96w%D8%DC%E9*Eh%0C%151(%00%00%00%00IEND%AEB%60%82");
background-repeat: no-repeat;
background-position: center 5px;
background-position: center 4px;
border-radius: 3px;
border: 1px solid transparent;
}
.ace_fold-widget.end {
@@ -262,11 +266,8 @@
.ace_fold-widget:hover {
border: 1px solid rgba(0, 0, 0, 0.3);
background-color: rgba(255, 255, 255, 0.2);
-moz-box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7);
-moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
-webkit-box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7);
-webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7);
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
background-position: center 4px;
}
@@ -274,14 +275,34 @@
.ace_fold-widget:active {
border: 1px solid rgba(0, 0, 0, 0.4);
background-color: rgba(0, 0, 0, 0.05);
-moz-box-shadow:inset 0 1px 1px rgba(255, 255, 255);
-moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
-webkit-box-shadow:inset 0 1px 1px rgba(255, 255, 255);
-webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
box-shadow:inset 0 1px 1px rgba(255, 255, 255);
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}
/**
* Dark version for fold widgets
*/
.ace_dark .ace_fold-widget {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC");
}
.ace_dark .ace_fold-widget.end {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==");
}
.ace_dark .ace_fold-widget.closed {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==");
}
.ace_dark .ace_fold-widget:hover {
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
background-color: rgba(255, 255, 255, 0.1);
}
.ace_dark .ace_fold-widget:active {
-moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
-webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
}
.ace_fold-widget.invalid {
background-color: #FFB4B4;
border-color: #DE5555;
@@ -94,7 +94,7 @@ function BracketMatch() {
var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
if (!match) {
chr = line.charAt(pos.column);
pos.column++;
pos = {row: pos.row, column: pos.column + 1};
match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
before = false;
}
@@ -123,9 +123,6 @@ function BracketMatch() {
range.cursor = range.start;
}
if (!before)
pos.column--;
return range;
};
@@ -194,7 +191,7 @@ function BracketMatch() {
return null;
};
this.$findClosingBracket = function(bracket, position, typeRe, allowBlankLine) {
this.$findClosingBracket = function(bracket, position, typeRe) {
var closingBracket = this.$brackets[bracket];
var depth = 1;
@@ -239,12 +236,6 @@ function BracketMatch() {
// whose type matches typeRe
do {
token = iterator.stepForward();
if (allowBlankLine) {
// if you've reached the doc end, or, you match a new content line
if (token === null || token.type == "string") {
return {row: iterator.getCurrentTokenRow() + (token === null ? 1 : -1), column: 0};
}
}
} while (token && !typeRe.test(token.type));
if (token == null)
@@ -1772,7 +1772,7 @@ var Editor = function(renderer, session) {
var range = this.session.getBracketRange(cursor);
if (!range) {
range = editor.find({
range = this.find({
needle: /[{}()\[\]]/g,
preventScroll:true,
start: {row: cursor.row, column: cursor.column - 1}
@@ -1787,10 +1787,10 @@ var Editor = function(renderer, session) {
pos = range && range.cursor || pos;
if (pos) {
if (select) {
if (range && range.isEqual(editor.getSelectionRange()))
if (range && range.isEqual(this.getSelectionRange()))
this.clearSelection();
else
this.selection.selectTo(pos.row, pos.column);
this.selection.selectTo(pos.row, pos.column);
} else {
this.clearSelection();
this.moveCursorTo(pos.row, pos.column);
@@ -105,7 +105,7 @@ StateHandler.prototype = {
var bufferObj = {
bufferToUse: bufferToUse,
symbolicName: symbolicName,
symbolicName: symbolicName
};
if (e) {
@@ -73,7 +73,7 @@ var Marker = function(parentEl) {
var html = [];
for ( var key in this.markers) {
for (var key in this.markers) {
var marker = this.markers[key];
if (!marker.range) {
@@ -140,29 +140,25 @@ var Marker = function(parentEl) {
}
};
// Draws a multi line marker, where lines span the full width
this.drawMultiLineMarker = function(stringBuilder, range, clazz, layerConfig, type) {
// Draws a multi line marker, where lines span the full width
this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, type) {
var padding = type === "background" ? 0 : this.$padding;
var layerWidth = layerConfig.width + 2 * this.$padding - padding;
// from selection start to the end of the line
var height = layerConfig.lineHeight;
var width = Math.round(layerWidth - (range.start.column * layerConfig.characterWidth));
var top = this.$getTop(range.start.row, layerConfig);
var left = Math.round(
padding + range.start.column * layerConfig.characterWidth
);
var height = config.lineHeight;
var top = this.$getTop(range.start.row, config);
var left = Math.round(padding + range.start.column * config.characterWidth);
stringBuilder.push(
"<div class='", clazz, " start' style='",
"height:", height, "px;",
"width:", width, "px;",
"right:0;",
"top:", top, "px;",
"left:", left, "px;'></div>"
);
// from start of the last line to the selection end
top = this.$getTop(range.end.row, layerConfig);
width = Math.round(range.end.column * layerConfig.characterWidth);
top = this.$getTop(range.end.row, config);
var width = Math.round(range.end.column * config.characterWidth);
stringBuilder.push(
"<div class='", clazz, "' style='",
@@ -173,15 +169,15 @@ var Marker = function(parentEl) {
);
// all the complete lines
height = (range.end.row - range.start.row - 1) * layerConfig.lineHeight;
height = (range.end.row - range.start.row - 1) * config.lineHeight;
if (height < 0)
return;
top = this.$getTop(range.start.row + 1, layerConfig);
top = this.$getTop(range.start.row + 1, config);
stringBuilder.push(
"<div class='", clazz, "' style='",
"height:", height, "px;",
"width:", layerWidth, "px;",
"right:0;",
"top:", top, "px;",
"left:", padding, "px;'></div>"
);
@@ -131,7 +131,7 @@ var Text = function(parentEl) {
container.appendChild(measureNode);
}
}
// Size and width can be null if the editor is not visible or
// detached from the document
if (!this.element.offsetWidth)
@@ -153,7 +153,7 @@ var Text = function(parentEl) {
return null;
return size;
}
}
: function() {
if (!this.$measureNode) {
var measureNode = this.$measureNode = dom.createElement("div");
@@ -178,7 +178,7 @@ var Text = function(parentEl) {
container.appendChild(measureNode);
}
var rect = this.$measureNode.getBoundingClientRect();
var size = {
@@ -382,7 +382,7 @@ var Text = function(parentEl) {
"lparen": true
};
this.$renderToken = function(stringBuilder, screenColumn, token, value) {
this.$renderToken = function(stringBuilder, screenColumn, token, value) {
var self = this;
var replaceReg = /\t|&|<|( +)|([\u0000-\u0019\u00a0\u1680\u180E\u2000-\u200b\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g;
var replaceFunc = function(c, a, b, tabIdx, idx4) {
@@ -447,7 +447,7 @@ var Text = function(parentEl) {
"'>"
);
}
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
var value = token.value;
@@ -461,12 +461,12 @@ var Text = function(parentEl) {
else {
while (chars + value.length >= splitChars) {
screenColumn = self.$renderToken(
stringBuilder, screenColumn,
stringBuilder, screenColumn,
token, value.substring(0, splitChars - chars)
);
value = value.substring(splitChars - chars);
chars = splitChars;
if (!onlyContents) {
stringBuilder.push("</div>",
"<div class='ace_line' style='height:",
@@ -510,9 +510,9 @@ var Text = function(parentEl) {
};
this.$renderFoldLine = function(stringBuilder, row, tokens, onlyContents) {
var session = this.session,
foldLine = session.getFoldLine(row),
renderTokens = [];
var session = this.session;
var foldLine = session.getFoldLine(row);
var renderTokens = [];
function addTokens(tokens, from, to) {
var idx = 0, col = 0;
@@ -520,16 +520,14 @@ var Text = function(parentEl) {
col += tokens[idx].value.length;
idx++;
if (idx == tokens.length) {
if (idx == tokens.length)
return;
}
}
if (col != from) {
var value = tokens[idx].value.substring(from - col);
// Check if the token value is longer then the from...to spacing.
if (value.length > (to - from)) {
if (value.length > (to - from))
value = value.substring(0, to - from);
}
renderTokens.push({
type: tokens[idx].type,
@@ -540,15 +538,15 @@ var Text = function(parentEl) {
idx += 1;
}
while (col < to) {
while (col < to && idx < tokens.length) {
var value = tokens[idx].value;
if (value.length + col > to) {
value = value.substring(0, to - col);
}
renderTokens.push({
type: tokens[idx].type,
value: value
});
renderTokens.push({
type: tokens[idx].type,
value: value.substring(0, to - col)
});
} else
renderTokens.push(tokens[idx]);
col += value.length;
idx += 1;
}
@@ -556,27 +554,27 @@ var Text = function(parentEl) {
foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
if (placeholder) {
renderTokens.push({
renderTokens.push({
type: "fold",
value: placeholder
});
} else {
if (isNewRow)
tokens = this.session.getTokens(row);
tokens = session.getTokens(row);
if (tokens.length)
addTokens(tokens, lastColumn, column);
}
}.bind(this), foldLine.end.row, this.session.getLine(foldLine.end.row).length);
}, foldLine.end.row, this.session.getLine(foldLine.end.row).length);
// TODO: Build a fake splits array!
var splits = this.session.$useWrapMode?this.session.$wrapData[row]:null;
// splits for foldline are stored at its' first row
var splits = this.session.$useWrapMode ? this.session.$wrapData[row] : null;
this.$renderLineCore(stringBuilder, row, renderTokens, splits, onlyContents);
};
this.$useLineGroups = function() {
// For the updateLines function to work correctly, it's important that the
// child nodes of this.element correspond on a 1-to-1 basis to rows in the
// child nodes of this.element correspond on a 1-to-1 basis to rows in the
// document (as distinct from lines on the screen). For sessions that are
// wrapped, this means we need to add a layer to the node hierarchy (tagged
// with the class name ace_line_group).
@@ -227,7 +227,7 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac
function normalizeCommandKeys(callback, e, keyCode) {
var hashId = 0;
if (useragent.isOpera && useragent.isMac) {
if ((useragent.isOpera && !("KeyboardEvent" in window)) && useragent.isMac) {
hashId = 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0)
| (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0);
} else {
@@ -268,7 +268,7 @@ function normalizeCommandKeys(callback, e, keyCode) {
exports.addCommandKeyListener = function(el, callback) {
var addListener = exports.addListener;
if (useragent.isOldGecko || useragent.isOpera) {
if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) {
// Old versions of Gecko aka. Firefox < 4.0 didn't repeat the keydown
// event if the user pressed the key for a longer time. Instead, the
// keydown event was fired once and later on only the keypress event.
@@ -0,0 +1,98 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Spencer <chris.ag.spencer AT googlemail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var XmlBehaviour = require("../behaviour/xml").XmlBehaviour;
var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
var TokenIterator = require("../../token_iterator").TokenIterator;
var voidElements = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
function hasType(token, type) {
var hasType = true;
var typeList = token.type.split('.');
var needleList = type.split('.');
needleList.forEach(function(needle){
if (typeList.indexOf(needle) == -1) {
hasType = false;
return false;
}
});
return hasType;
}
var HtmlBehaviour = function () {
this.inherit(XmlBehaviour); // Get xml behaviour
this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
if (text == '>') {
var position = editor.getCursorPosition();
var iterator = new TokenIterator(session, position.row, position.column);
var token = iterator.getCurrentToken();
var atCursor = false;
if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
do {
token = iterator.stepBackward();
} while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text')));
} else {
atCursor = true;
}
if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) {
return
}
var element = token.value;
if (atCursor){
var element = element.substring(0, position.column - token.start);
}
if (voidElements.indexOf(element) !== -1){
return;
}
return {
text: '>' + '</' + element + '>',
selection: [1, 1]
}
}
});
}
oop.inherits(HtmlBehaviour, XmlBehaviour);
exports.HtmlBehaviour = HtmlBehaviour;
});
@@ -42,34 +42,55 @@ define(function(require, exports, module) {
var oop = require("../../lib/oop");
var Behaviour = require("../behaviour").Behaviour;
var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
var TokenIterator = require("../../token_iterator").TokenIterator;
function hasType(token, type) {
var hasType = true;
var typeList = token.type.split('.');
var needleList = type.split('.');
needleList.forEach(function(needle){
if (typeList.indexOf(needle) == -1) {
hasType = false;
return false;
}
});
return hasType;
}
var XmlBehaviour = function () {
this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour
this.add("brackets", "insertion", function (state, action, editor, session, text) {
if (text == '<') {
var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection);
if (selected !== "") {
return false;
this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
if (text == '>') {
var position = editor.getCursorPosition();
var iterator = new TokenIterator(session, position.row, position.column);
var token = iterator.getCurrentToken();
var atCursor = false;
if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
do {
token = iterator.stepBackward();
} while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text')));
} else {
return {
text: '<>',
selection: [1, 1]
}
atCursor = true;
}
} else if (text == '>') {
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '>') { // need some kind of matching check here
return {
text: '',
selection: [1, 1]
}
if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) {
return
}
} else if (text == "\n") {
var tag = token.value;
if (atCursor){
var tag = tag.substring(0, position.column - token.start);
}
return {
text: '>' + '</' + tag + '>',
selection: [1, 1]
}
}
});
this.add('autoindent', 'insertion', function (state, action, editor, session, text) {
if (text == "\n") {
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
var rightChars = line.substring(cursor.column, cursor.column + 2);
@@ -56,18 +56,6 @@ oop.inherits(Mode, TextMode);
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
// ignore braces in comments
var tokens = this.$tokenizer.getLineTokens(line, state).tokens;
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;
}
var match = line.match(/^.*\{\s*$/);
if (match) {
indent += tab;
}
return indent;
};
@@ -48,7 +48,7 @@ var C9SearchHighlightRules = function() {
this.$rules = {
"start" : [
{
token : ["constant.numeric", "text", "text"],
token : ["c9searchresults.constant.numeric", "c9searchresults.text", "c9searchresults.text"],
regex : "(^\\s+[0-9]+)(:\\s*)(.+)"
},
{
@@ -41,7 +41,7 @@ define(function(require, exports, module) {
var Tokenizer = require("../tokenizer").Tokenizer;
var Rules = require("./coffee_highlight_rules").CoffeeHighlightRules;
var Outdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var PythonFoldMode = require("./folding/pythonic").FoldMode;
var PythonFoldMode = require("./folding/coffee").FoldMode;
var Range = require("../range").Range;
var TextMode = require("./text").Mode;
var WorkerClient = require("../worker/worker_client").WorkerClient;
@@ -153,7 +153,7 @@ define(function(require, exports, module) {
regex : "\\?|\\:|\\,|\\."
}, {
token : "keyword.operator",
regex : "(?:[\\-=]>|[-+*/%<>&|^!?=]=|>>>=?|\\-\\-|\\+\\+|::|&&=|\\|\\|=|<<=|>>=|\\?\\.|\\.{2,3}|\\!)"
regex : "(?:[\\-=]>|[-+*/%<>&|^!?=]=|>>>=?|\\-\\-|\\+\\+|::|&&=|\\|\\|=|<<=|>>=|\\?\\.|\\.{2,3}|[!*+-=><])"
}, {
token : "paren.lparen",
regex : "[({[]"
@@ -19,7 +19,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Garen J. Torikian <gjtorikian AT gmail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -48,46 +48,32 @@ oop.inherits(FoldMode, BaseFoldMode);
(function() {
this.foldingStartMarker = /[a-zA-Z](:)\s*$/;
this.foldingStopMarker = /^(\s*)$/;
this.foldingStartMarker = /^(\w.*\:|Searching for.*)$/;
this.foldingStopMarker = /^(\s+|Found.*)$/;
this.getFoldWidgetRange = function(session, foldStyle, row) {
var line = session.getLine(row);
var match = line.match(this.foldingStartMarker);
if (match) {
var i = match.index;
var level1 = /^(Found.*|Searching for.*)$/;
var level2 = /^(\w.*\:|\s*)$/;
var re = level1.test(line) ? level1 : level2;
if (match[1])
return this.openingBracketBlock(session, match[1], row, i, false, true);
var range = session.getCommentFoldRange(row, i + match[0].length);
range.end.column -= 2;
return range;
}
if (foldStyle !== "markbeginend")
return;
var match = line.match(this.foldingStopMarker);
if (match) {
var i = match.index + match[0].length;
if (match[2]) {
var range = session.getCommentFoldRange(row, i);
range.end.column -= 2;
return range;
if (this.foldingStartMarker.test(line)) {
for (var i = row + 1, l = session.getLength(); i < l; i++) {
if (re.test(session.getLine(i)))
break;
}
var end = {row: row, column: i};
var start = session.$findOpeningBracket(match[1], end);
if (!start)
return;
return new Range(row, line.length, i, 0);
}
start.column++;
end.column--;
if (this.foldingStopMarker.test(line)) {
for (var i = row - 1; i >= 0; i--) {
line = session.getLine(i);
if (re.test(line))
break;
}
return Range.fromPoints(start, end);
return new Range(i, line.length, row, 0);
}
};
@@ -0,0 +1,127 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var BaseFoldMode = require("./fold_mode").FoldMode;
var Range = require("../../range").Range;
var FoldMode = exports.FoldMode = function() {};
oop.inherits(FoldMode, BaseFoldMode);
(function() {
this.getFoldWidgetRange = function(session, foldStyle, row) {
var range = this.indentationBlock(session, row);
if (range)
return range;
var re = /\S/;
var line = session.getLine(row);
var startLevel = line.search(re);
if (startLevel == -1 || line[startLevel] != "#")
return;
var startColumn = line.length;
var maxRow = session.getLength();
var startRow = row;
var endRow = row;
while (++row < maxRow) {
line = session.getLine(row);
var level = line.search(re);
if (level == -1)
continue;
if (line[level] != "#")
break;
endRow = row;
}
if (endRow > startRow) {
var endColumn = session.getLine(endRow).length;
return new Range(startRow, startColumn, endRow, endColumn);
}
};
// must return "" if there's no fold, to enable caching
this.getFoldWidget = function(session, foldStyle, row) {
var line = session.getLine(row);
var indent = line.search(/\S/);
var next = session.getLine(row + 1);
var prev = session.getLine(row - 1);
var prevIndent = prev.search(/\S/);
var nextIndent = next.search(/\S/);
if (indent == -1) {
session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
return "";
}
// documentation comments
if (prevIndent == -1) {
if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
session.foldWidgets[row - 1] = "";
session.foldWidgets[row + 1] = "";
return "start";
}
} else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
if (session.getLine(row - 2).search(/\S/) == -1) {
session.foldWidgets[row - 1] = "start";
session.foldWidgets[row + 1] = "";
return ""
}
}
if (prevIndent!= -1 && prevIndent < indent)
session.foldWidgets[row - 1] = "start";
else
session.foldWidgets[row - 1] = "";
if (indent < nextIndent)
return "start";
else
return "";
};
}).call(FoldMode.prototype);
});
@@ -0,0 +1,108 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
if (typeof process !== "undefined")
require("amd-loader");
define(function(require, exports, module) {
"use strict";
var CoffeeMode = require("../coffee").Mode;
var EditSession = require("../../edit_session").EditSession;
var assert = require("../../test/assertions");
function testFoldWidgets(array) {
var session = array.filter(function(_, i){return i % 2 == 1});
session = new EditSession(session);
var mode = new CoffeeMode();
session.setFoldStyle("markbeginend");
session.setMode(mode);
var widgets = array.filter(function(_, i){return i % 2 == 0});
widgets.forEach(function(w, i){
session.foldWidgets[i] = session.getFoldWidget(i);
})
widgets.forEach(function(w, i){
w = w.split(",");
var type = w[0] == ">" ? "start" : w[0] == "<" ? "end" : "";
assert.equal(session.foldWidgets[i], type);
if (!type)
return;
var range = session.getFoldWidgetRange(i);
if (!w[1]) {
assert.equal(range, null);
return;
}
assert.equal(range.start.row, i);
assert.equal(range.end.row - range.start.row, parseInt(w[1]));
testColumn(w[2], range.start);
testColumn(w[3], range.end);
});
function testColumn(w, pos) {
if (!w)
return;
if (w == "l")
w = session.getLine(pos.row).length;
else
w = parseInt(w);
assert.equal(pos.column, w);
}
}
module.exports = {
"test: coffee script indentation based folding": function() {
testFoldWidgets([
'>,1,l,l', ' ## indented comment',
'', ' # ',
'', '',
'>,1,l,l', ' # plain comment',
'', ' # ',
'>,2', ' function (x)=>',
'', ' ',
'', ' x++',
'', ' ',
'', ' ',
'>,2', ' bar = ',
'', ' foo: 1',
'', ' baz: lighter'
]);
}
};
});
if (typeof module !== "undefined" && module === require.main)
require("asyncjs").test.testcase(module.exports).exec();
@@ -58,25 +58,27 @@ var FoldMode = exports.FoldMode = function() {};
return "end";
return "";
};
this.getFoldWidgetRange = function(session, foldStyle, row) {
return null;
};
this.indentationBlock = function(session, row, column) {
var re = /^\s*/;
var re = /\S/;
var line = session.getLine(row);
var startLevel = line.search(re);
if (startLevel == -1)
return;
var startColumn = column || line.length;
var maxRow = session.getLength();
var startRow = row;
var endRow = row;
var line = session.getLine(row);
var startColumn = column || line.length;
var startLevel = line.match(re)[0].length;
var maxRow = session.getLength()
while (++row < maxRow) {
line = session.getLine(row);
var level = line.match(re)[0].length;
if (level == line.length)
while (++row < maxRow) {
var level = session.getLine(row).search(re);
if (level == -1)
continue;
if (level <= startLevel)
@@ -91,9 +93,9 @@ var FoldMode = exports.FoldMode = function() {};
}
};
this.openingBracketBlock = function(session, bracket, row, column, typeRe, allowBlankLine) {
this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
var start = {row: row, column: column + 1};
var end = session.$findClosingBracket(bracket, start, typeRe, allowBlankLine);
var end = session.$findClosingBracket(bracket, start, typeRe);
if (!end)
return;
@@ -101,7 +103,7 @@ var FoldMode = exports.FoldMode = function() {};
if (fw == null)
fw = this.getFoldWidget(session, end.row);
if (fw == "start") {
if (fw == "start" && end.row > start.row) {
end.row --;
end.column = session.getLine(end.row).length;
}
@@ -42,7 +42,7 @@ var oop = require("../../lib/oop");
var BaseFoldMode = require("./fold_mode").FoldMode;
var FoldMode = exports.FoldMode = function(markers) {
this.foldingStartMarker = new RegExp("(?:([\\[{])|(" + markers + "))(?:\\s*)(?:#.*)?$");
this.foldingStartMarker = new RegExp("([\\[{])(?:\\s*)$|(" + markers + ")(?:\\s*)(?:#.*)?$");
};
oop.inherits(FoldMode, BaseFoldMode);
@@ -49,11 +49,12 @@ module.exports = {
"test: bracket folding": function() {
var session = new EditSession([
'[ #-',
'[ ',
'stuff',
']',
'[ ',
'{ '
'{ ',
'[ #-',
]);
var mode = new PythonMode();
@@ -65,9 +66,11 @@ module.exports = {
assert.equal(session.getFoldWidget(2), "");
assert.equal(session.getFoldWidget(3), "start");
assert.equal(session.getFoldWidget(4), "start");
assert.equal(session.getFoldWidget(5), "");
assert.range(session.getFoldWidgetRange(0), 0, 1, 2, 0);
assert.equal(session.getFoldWidgetRange(3), null);
assert.equal(session.getFoldWidgetRange(5), null);
},
"test: indentation folding": function() {
@@ -44,13 +44,13 @@ var JavaScriptMode = require("./javascript").Mode;
var CssMode = require("./css").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
var HtmlBehaviour = require("./behaviour/html").HtmlBehaviour;
var HtmlFoldMode = require("./folding/html").FoldMode;
var Mode = function() {
var highlighter = new HtmlHighlightRules();
this.$tokenizer = new Tokenizer(highlighter.getRules());
this.$behaviour = new XmlBehaviour();
this.$behaviour = new HtmlBehaviour();
this.$embeds = highlighter.getEmbeds();
this.createModeDelegates({
@@ -44,6 +44,25 @@ var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScrip
var xmlUtil = require("./xml_util");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var tagMap = {
a : 'anchor',
button : 'form',
form : 'form',
img : 'image',
input : 'form',
label : 'form',
script : 'script',
select : 'form',
textarea : 'form',
style : 'style',
table : 'table',
tbody : 'table',
td : 'table',
tfoot : 'table',
th : 'table',
tr : 'table'
};
var HtmlHighlightRules = function() {
// regexp must not have capturing parentheses
@@ -113,9 +132,9 @@ var HtmlHighlightRules = function() {
} ]
};
xmlUtil.tag(this.$rules, "tag", "start");
xmlUtil.tag(this.$rules, "style", "css-start");
xmlUtil.tag(this.$rules, "script", "js-start");
xmlUtil.tag(this.$rules, "tag", "start", tagMap);
xmlUtil.tag(this.$rules, "style", "css-start", tagMap);
xmlUtil.tag(this.$rules, "script", "js-start", tagMap);
this.embedRules(JavaScriptHighlightRules, "js-", [{
token: "comment",
@@ -380,7 +380,7 @@ var JavaScriptHighlightRules = function() {
"function_arguments": [
{
token: "variable.parameter",
regex: identifierRe,
regex: identifierRe
}, {
token: "punctuation.operator",
regex: "[, ]+",
@@ -1,4 +1,4 @@
define(function(require, exports, module) {
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
@@ -1,4 +1,4 @@
// LuaPage implements the LuaPage markup as described by the Kepler Project's CGILua
// LuaPage implements the LuaPage markup as described by the Kepler Project's CGILua
// documentation: http://keplerproject.github.com/cgilua/manual.html#templates
define(function(require, exports, module) {
"use strict";
@@ -38,16 +38,6 @@
define(function(require, exports, module) {
"use strict";
var lang = require("../lib/lang");
var formTags = lang.arrayToMap(
("button|form|input|label|select|textarea").split("|")
);
var tableTags = lang.arrayToMap(
("table|tbody|td|tfoot|th|tr").split("|")
);
function string(state) {
return [{
token : "string",
@@ -81,7 +71,7 @@ function multiLineString(quote, state) {
}];
}
exports.tag = function(states, name, nextState) {
exports.tag = function(states, name, nextState, tagMap) {
states[name] = [{
token : "text",
regex : "\\s+"
@@ -89,26 +79,10 @@ exports.tag = function(states, name, nextState) {
//token : "meta.tag",
token : function(value) {
if ( value==='a' ) {
return "meta.tag.anchor";
}
else if ( value==='img' ) {
return "meta.tag.image";
}
else if ( value==='script' ) {
return "meta.tag.script";
}
else if ( value==='style' ) {
return "meta.tag.style";
}
else if (formTags.hasOwnProperty(value.toLowerCase())) {
return "meta.tag.form";
}
else if (tableTags.hasOwnProperty(value.toLowerCase())) {
return "meta.tag.table";
}
else {
return "meta.tag";
if (tagMap && tagMap[value]) {
return "meta.tag.tag-name" + '.' + tagMap[value];
} else {
return "meta.tag.tag-name";
}
},
merge : true,
@@ -58,13 +58,10 @@ function GutterHandler(mouseHandler) {
var row = e.getDocumentPosition().row;
var selection = editor.session.selection;
if (e.getShiftKey()) {
if (e.getShiftKey())
selection.selectTo(row, 0);
} else {
selection.moveCursorTo(row, 0);
selection.selectLine();
mouseHandler.$clickSelection = selection.getRange();
}
else
mouseHandler.$clickSelection = editor.selection.getLineRange(row);
mouseHandler.captureMouse(e, "selectByLines");
return e.preventDefault();
@@ -65,7 +65,7 @@ function DefaultHandlers(mouseHandler) {
mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
mouseHandler.$focusWaitTimout = 250;
}
@@ -163,10 +163,12 @@ function DefaultHandlers(mouseHandler) {
if (cmpStart == -1 && cmpEnd <= 0) {
anchor = this.$clickSelection.end;
cursor = range.start;
if (range.end.row != cursor.row || range.end.column != cursor.column)
cursor = range.start;
} else if (cmpEnd == 1 && cmpStart >= 0) {
anchor = this.$clickSelection.start;
cursor = range.end;
if (range.start.row != cursor.row || range.start.column != cursor.column)
cursor = range.end;
} else if (cmpStart == -1 && cmpEnd == 1) {
cursor = range.end;
anchor = range.start;
@@ -286,7 +288,7 @@ function DefaultHandlers(mouseHandler) {
this.setState("select");
return;
}
this.$clickSelection = editor.selection.getWordRange(pos.row, pos.column);
this.setState("selectByWords");
};
@@ -296,10 +298,7 @@ function DefaultHandlers(mouseHandler) {
var editor = this.editor;
this.setState("selectByLines");
editor.moveCursorToPosition(pos);
editor.selection.selectLine();
this.$clickSelection = editor.getSelectionRange();
this.$clickSelection = editor.selection.getLineRange(pos.row);
};
this.onQuadClick = function(ev) {
@@ -345,7 +344,7 @@ function calcRangeOrientation(range, cursor) {
var cmp = 2 * cursor.column - range.start.column - range.end.column;
else
var cmp = 2 * cursor.row - range.start.row - range.end.row;
if (cmp < 0)
return {cursor: range.start, anchor: range.end};
else
@@ -41,17 +41,17 @@
(function() {
var globalRequire = require;
var globalRequire = typeof require != "undefined" && require;
define(function (require, exports, module) {
"use strict";
exports.load = function (name, req, onLoad, config) {
if (req.isBrowser)
require("ace/lib/net").get(req.toUrl(name), onLoad);
//Using special require.nodeRequire, something added by r.js.
if (globalRequire && globalRequire.nodeRequire)
onLoad(('fs').readFileSync(req.toUrl(name), 'utf8'));
else
//Using special require.nodeRequire, something added by r.js.
onLoad(globalRequire.nodeRequire('fs').readFileSync(req.toUrl(name), 'utf8'));
require("ace/lib/net").get(req.toUrl(name), onLoad);
};
});
@@ -42,6 +42,7 @@ var testNames = [
"ace/mode/folding/html_test",
"ace/mode/folding/pythonic_test",
"ace/mode/folding/xml_test",
"ace/mode/folding/coffee_test",
"ace/multi_select_test",
"ace/range_test",
"ace/range_list_test",
@@ -7,7 +7,7 @@
}
.ace-chrome .ace_gutter {
background: #e8e8e8;
background: #ebebeb;
color: #333;
overflow : hidden;
}
@@ -18,7 +18,6 @@
}
.ace-chrome .ace_text-layer {
cursor: text;
}
.ace-chrome .ace_cursor {
@@ -151,7 +150,10 @@ color:#FD971F;
color: rgb(255, 0, 0)
}
.ace-chrome .ace_line .ace_string,
.ace-chrome .ace_line .ace_string{
color: #1A1AA6;
}
.ace-chrome .ace_entity.ace_other.ace_attribute-name{
color: #994409;
}
@@ -8,7 +8,7 @@
}
.ace-clouds .ace_gutter {
background: #e8e8e8;
background: #ebebeb;
color: #333;
}
@@ -22,7 +22,6 @@
}
.ace-clouds .ace_text-layer {
cursor: text;
color: #000000;
}
@@ -8,13 +8,13 @@
}
.ace-clouds-midnight .ace_gutter {
background: #e8e8e8;
color: #333;
background: #232323;
color: #929292;
}
.ace-clouds-midnight .ace_print_margin {
width: 1px;
background: #e8e8e8;
background: #232323;
}
.ace-clouds-midnight .ace_scroller {
@@ -22,7 +22,6 @@
}
.ace-clouds-midnight .ace_text-layer {
cursor: text;
color: #929292;
}
@@ -58,7 +57,7 @@
}
.ace-clouds-midnight .ace_gutter_active_line {
background-color : #dcdcdc;
background-color: rgba(215, 215, 215, 0.031);
}
.ace-clouds-midnight .ace_marker-layer .ace_selected_word {
@@ -8,13 +8,13 @@
}
.ace-cobalt .ace_gutter {
background: #e8e8e8;
color: #333;
background: #011e3a;
color: #fff;
}
.ace-cobalt .ace_print_margin {
width: 1px;
background: #e8e8e8;
background: #011e3a;
}
.ace-cobalt .ace_scroller {
@@ -22,7 +22,6 @@
}
.ace-cobalt .ace_text-layer {
cursor: text;
color: #FFFFFF;
}
@@ -58,7 +57,7 @@
}
.ace-cobalt .ace_gutter_active_line {
background-color : #dcdcdc;
background-color : rgba(0, 0, 0, 0.35);
}
.ace-cobalt .ace_marker-layer .ace_selected_word {
@@ -7,7 +7,7 @@
}
.ace-crimson-editor .ace_gutter {
background: #e8e8e8;
background: #ebebeb;
color: #333;
overflow : hidden;
}
@@ -23,7 +23,6 @@
}
.ace-crimson-editor .ace_text-layer {
cursor: text;
color: rgb(64, 64, 64);
}
@@ -134,6 +133,10 @@
background: rgb(232, 242, 254);
}
.ace-crimson-editor .ace_gutter_active_line {
background-color : #dcdcdc;
}
.ace-crimson-editor .ace_meta.ace_tag {
color:rgb(28, 2, 255);
}
@@ -8,7 +8,7 @@
}
.ace-dawn .ace_gutter {
background: #e8e8e8;
background: #ebebeb;
color: #333;
}
@@ -22,7 +22,6 @@
}
.ace-dawn .ace_text-layer {
cursor: text;
color: #080808;
}
@@ -21,7 +21,6 @@
}
.ace-dreamweaver .ace_text-layer {
cursor: text;
}
.ace-dreamweaver .ace_cursor {
@@ -7,14 +7,14 @@
}
.ace-eclipse .ace_gutter {
background: rgb(227, 227, 227);
background: #ebebeb;
border-right: 1px solid rgb(159, 159, 159);
color: rgb(136, 136, 136);
}
.ace-eclipse .ace_print_margin {
width: 1px;
background: #b1b4ba;
background: #ebebeb;
}
.ace-eclipse .ace_fold {
@@ -22,7 +22,6 @@
}
.ace-eclipse .ace_text-layer {
cursor: text;
}
.ace-eclipse .ace_cursor {
@@ -13,6 +13,15 @@
margin-bottom: 15px;
}
.ace-github .ace_gutter {
background: #e8e8e8;
color: #AAA;
}
.ace-github .ace_scroller {
background: #fff;
}
.ace-github .ace_keyword {
font-weight: bold;
}
@@ -29,6 +38,14 @@
color: #099;
}
.ace-github .ace_constant.ace_buildin {
color: #0086B3;
}
.ace-github .ace_support.ace_function {
color: #0086B3;
}
.ace-github .ace_comment {
color: #998;
font-style: italic;
@@ -38,12 +55,11 @@
color: #0086B3;
}
.ace-github .ace_paren.ace_lparen,
.ace-github .ace_paren.ace_rparen {
.ace-github .ace_paren {
font-weight: bold;
}
.ace-github .ace_constant.ace_language.ace_boolean {
.ace-github .ace_boolean {
font-weight: bold;
}
@@ -61,7 +77,6 @@
}
.ace-github .ace_text-layer {
cursor: text;
}
.ace-github .ace_cursor {
@@ -73,10 +88,46 @@
border-bottom: 1px solid black;
}
.ace-github .ace_marker-layer .ace_active_line {
background: rgb(255, 255, 204);
}
.ace-github .ace_marker-layer .ace_selection {
background: rgb(181, 213, 255);
}
.ace-github.multiselect .ace_selection.start {
box-shadow: 0 0 3px 0px white;
border-radius: 2px;
}
/* bold keywords cause cursor issues for some fonts */
/* this disables bold style for editor and keeps for static highlighter */
.ace-github.ace_editor .ace_line > span {
font-weight: normal !important;
}
.ace-github .ace_marker-layer .ace_step {
background: rgb(252, 255, 0);
}
.ace-github .ace_marker-layer .ace_stack {
background: rgb(164, 229, 101);
}
.ace-github .ace_marker-layer .ace_bracket {
margin: -1px 0 0 -1px;
border: 1px solid rgb(192, 192, 192);
}
.ace-github .ace_gutter_active_line{
background-color : rgba(0, 0, 0, 0.07);
}
.ace-github .ace_marker-layer .ace_selected_word {
background: rgb(250, 250, 255);
border: 1px solid rgb(200, 200, 250);
}
.ace-github .ace_print_margin {
width: 1px;
background: #e8e8e8;
}
@@ -37,7 +37,7 @@
define(function(require, exports, module) {
exports.isDark = true;
exports.isDark = false;
exports.cssClass = "ace-github";
exports.cssText = require('ace/requirejs/text!./github.css');
@@ -8,13 +8,13 @@
}
.ace-idle-fingers .ace_gutter {
background: #e8e8e8;
color: #333;
background: #3b3b3b;
color: #fff;
}
.ace-idle-fingers .ace_print_margin {
width: 1px;
background: #e8e8e8;
background: #3b3b3b;
}
.ace-idle-fingers .ace_scroller {
@@ -22,7 +22,6 @@
}
.ace-idle-fingers .ace_text-layer {
cursor: text;
color: #FFFFFF;
}
@@ -58,7 +57,7 @@
}
.ace-idle-fingers .ace_gutter_active_line {
background-color : #dcdcdc;
background-color: #353637;
}
.ace-idle-fingers .ace_marker-layer .ace_selected_word {
@@ -8,13 +8,13 @@
}
.ace-kr-theme .ace_gutter {
background: #e8e8e8;
color: #333;
background: #1c1917;
color: #FCFFE0;
}
.ace-kr-theme .ace_print_margin {
width: 1px;
background: #e8e8e8;
background: #1c1917;
}
.ace-kr-theme .ace_scroller {
@@ -22,7 +22,6 @@
}
.ace-kr-theme .ace_text-layer {
cursor: text;
color: #FCFFE0;
}
@@ -58,7 +57,7 @@
}
.ace-kr-theme .ace_gutter_active_line {
background-color : #dcdcdc;
background-color : #38403D;
}
.ace-kr-theme .ace_marker-layer .ace_selected_word {
@@ -8,8 +8,8 @@
}
.ace-merbivore .ace_gutter {
background: #e8e8e8;
color: #333;
background: #202020;
color: #E6E1DC;
}
.ace-merbivore .ace_print_margin {
@@ -22,7 +22,6 @@
}
.ace-merbivore .ace_text-layer {
cursor: text;
color: #E6E1DC;
}
@@ -58,7 +57,7 @@
}
.ace-merbivore .ace_gutter_active_line {
background-color : #dcdcdc;
background-color : #333435;
}
.ace-merbivore .ace_marker-layer .ace_selected_word {
@@ -8,13 +8,13 @@
}
.ace-merbivore-soft .ace_gutter {
background: #e8e8e8;
color: #333;
background: #262424;
color: #E6E1DC;
}
.ace-merbivore-soft .ace_print_margin {
width: 1px;
background: #e8e8e8;
background: #262424;
}
.ace-merbivore-soft .ace_scroller {
@@ -22,7 +22,6 @@
}
.ace-merbivore-soft .ace_text-layer {
cursor: text;
color: #E6E1DC;
}
@@ -58,7 +57,7 @@
}
.ace-merbivore-soft .ace_gutter_active_line {
background-color : #dcdcdc;
background-color: #333435;
}
.ace-merbivore-soft .ace_marker-layer .ace_selected_word {
@@ -8,8 +8,8 @@
}
.ace-mono-industrial .ace_gutter {
background: #e8e8e8;
color: #333;
background: #1d2521;
color: #fff;
}
.ace-mono-industrial .ace_print_margin {
@@ -22,7 +22,6 @@
}
.ace-mono-industrial .ace_text-layer {
cursor: text;
color: #FFFFFF;
}
@@ -58,7 +57,7 @@
}
.ace-mono-industrial .ace_gutter_active_line {
background-color : #dcdcdc;
background-color: rgba(12, 13, 12, 0.25);
}
.ace-mono-industrial .ace_marker-layer .ace_selected_word {
@@ -8,7 +8,7 @@
}
.ace-monokai .ace_gutter {
background: #292a24;
background: #2f3129;
color: #f1f1f1;
}
@@ -22,7 +22,6 @@
}
.ace-monokai .ace_text-layer {
cursor: text;
color: #F8F8F2;
}
@@ -8,13 +8,13 @@
}
.ace-pastel-on-dark .ace_gutter {
background: #e8e8e8;
color: #333;
background: #353030;
color: #8F938F;
}
.ace-pastel-on-dark .ace_print_margin {
width: 1px;
background: #e8e8e8;
background: #353030;
}
.ace-pastel-on-dark .ace_scroller {
@@ -22,7 +22,6 @@
}
.ace-pastel-on-dark .ace_text-layer {
cursor: text;
color: #8F938F;
}
@@ -58,7 +57,7 @@
}
.ace-pastel-on-dark .ace_gutter_active_line {
background-color : #dcdcdc;
background-color: rgba(255, 255, 255, 0.031);
}
.ace-pastel-on-dark .ace_marker-layer .ace_selected_word {
@@ -8,7 +8,7 @@
}
.ace-solarized-dark .ace_gutter {
background: #09222b;
background: #01313f;
color: #d0edf7;
}
@@ -22,7 +22,6 @@
}
.ace-solarized-dark .ace_text-layer {
cursor: text;
color: #93A1A1;
}
@@ -8,7 +8,7 @@
}
.ace-solarized-light .ace_gutter {
background: #e8e8e8;
background: #fbf1d3;
color: #333;
}
@@ -22,7 +22,6 @@
}
.ace-solarized-light .ace_text-layer {
cursor: text;
color: #586E75;
}
@@ -7,7 +7,7 @@
}
.ace-tm .ace_gutter {
background: #e8e8e8;
background: #f0f0f0;
color: #333;
}
@@ -21,7 +21,6 @@
}
.ace-tm .ace_text-layer {
cursor: text;
}
.ace-tm .ace_cursor {
@@ -147,7 +146,8 @@
.ace-tm .ace_marker-layer .ace_active_line {
background: rgba(0, 0, 0, 0.07);
}
.ace-tm .ace_gutter_active_line{
.ace-tm .ace_gutter_active_line {
background-color : #dcdcdc;
}
@@ -8,13 +8,13 @@
}
.ace-tomorrow .ace_gutter {
background: #e8e8e8;
color: #333;
background: #f6f6f6;
color: #4D4D4C;
}
.ace-tomorrow .ace_print_margin {
width: 1px;
background: #e8e8e8;
background: #f6f6f6;
}
.ace-tomorrow .ace_scroller {
@@ -22,7 +22,6 @@
}
.ace-tomorrow .ace_text-layer {
cursor: text;
color: #4D4D4C;
}
@@ -8,13 +8,13 @@
}
.ace-tomorrow-night .ace_gutter {
background: #e8e8e8;
color: #333;
background: #25282c;
color: #C5C8C6;
}
.ace-tomorrow-night .ace_print_margin {
width: 1px;
background: #e8e8e8;
background: #25282c;
}
.ace-tomorrow-night .ace_scroller {
@@ -22,7 +22,6 @@
}
.ace-tomorrow-night .ace_text-layer {
cursor: text;
color: #C5C8C6;
}
@@ -58,7 +57,7 @@
}
.ace-tomorrow-night .ace_gutter_active_line {
background-color : #dcdcdc;
background-color: #282A2E;
}
.ace-tomorrow-night .ace_marker-layer .ace_selected_word {
@@ -8,13 +8,13 @@
}
.ace-tomorrow-night-blue .ace_gutter {
background: #022346;
background: #00204b;
color: #7388b5;
}
.ace-tomorrow-night-blue .ace_print_margin {
width: 1px;
background: #e8e8e8;
background: #00204b;
}
.ace-tomorrow-night-blue .ace_scroller {
@@ -22,7 +22,6 @@
}
.ace-tomorrow-night-blue .ace_text-layer {
cursor: text;
color: #FFFFFF;
}
@@ -8,13 +8,13 @@
}
.ace-tomorrow-night-bright .ace_gutter {
background: #e8e8e8;
color: #333;
background: #1a1a1a;
color: #DEDEDE;
}
.ace-tomorrow-night-bright .ace_print_margin {
width: 1px;
background: #e8e8e8;
background: #1a1a1a;
}
.ace-tomorrow-night-bright .ace_scroller {
@@ -22,7 +22,6 @@
}
.ace-tomorrow-night-bright .ace_text-layer {
cursor: text;
color: #DEDEDE;
}
@@ -58,7 +57,7 @@
}
.ace-tomorrow-night-bright .ace_gutter_active_line {
background-color : #dcdcdc;
background-color: #2A2A2A;
}
.ace-tomorrow-night-bright .ace_marker-layer .ace_selected_word {
@@ -8,13 +8,13 @@
}
.ace-tomorrow-night-eighties .ace_gutter {
background: #e8e8e8;
color: #333;
background: #272727;
color: #CCC;
}
.ace-tomorrow-night-eighties .ace_print_margin {
width: 1px;
background: #e8e8e8;
background: #272727;
}
.ace-tomorrow-night-eighties .ace_scroller {
@@ -22,7 +22,6 @@
}
.ace-tomorrow-night-eighties .ace_text-layer {
cursor: text;
color: #CCCCCC;
}
@@ -58,7 +57,7 @@
}
.ace-tomorrow-night-eighties .ace_gutter_active_line {
background-color : #dcdcdc;
background-color: #393939;
}
.ace-tomorrow-night-eighties .ace_marker-layer .ace_selected_word {
@@ -8,13 +8,13 @@
}
.ace-twilight .ace_gutter {
background: #e8e8e8;
color: #333;
background: #232323;
color: #F8F8F8;
}
.ace-twilight .ace_print_margin {
width: 1px;
background: #e8e8e8;
background: #232323;
}
.ace-twilight .ace_scroller {
@@ -22,7 +22,6 @@
}
.ace-twilight .ace_text-layer {
cursor: text;
color: #F8F8F8;
}
@@ -58,7 +57,7 @@
}
.ace-twilight .ace_gutter_active_line {
background-color : #dcdcdc;
background-color: rgba(255, 255, 255, 0.031);
}
.ace-twilight .ace_marker-layer .ace_selected_word {
@@ -8,13 +8,13 @@
}
.ace-vibrant-ink .ace_gutter {
background: #e8e8e8;
color: #333;
background: #1a1a1a;
color: white;
}
.ace-vibrant-ink .ace_print_margin {
width: 1px;
background: #e8e8e8;
background: #1a1a1a;
}
.ace-vibrant-ink .ace_scroller {
@@ -22,7 +22,6 @@
}
.ace-vibrant-ink .ace_text-layer {
cursor: text;
color: #FFFFFF;
}
@@ -58,7 +57,7 @@
}
.ace-vibrant-ink .ace_gutter_active_line {
background-color : #dcdcdc;
background-color: #333333;
}
.ace-vibrant-ink .ace_marker-layer .ace_selected_word {
@@ -263,8 +263,13 @@ var VirtualRenderer = function(container, theme) {
*
* Triggers a full update of all the layers, for all the rows.
**/
this.updateFull = function() {
this.$loop.schedule(this.CHANGE_FULL);
this.updateFull = function(force) {
if (force){
this.$renderChanges(this.CHANGE_FULL, true);
}
else {
this.$loop.schedule(this.CHANGE_FULL);
}
};
/**
@@ -282,11 +287,19 @@ var VirtualRenderer = function(container, theme) {
*
* [Triggers a resize of the editor.]{: #VirtualRenderer.onResize}
**/
this.onResize = function(force) {
this.onResize = function(force, gutterWidth, width, height) {
var changes = this.CHANGE_SIZE;
var size = this.$size;
var height = dom.getInnerHeight(this.container);
if (this.resizing > 2)
return;
else if (this.resizing > 1)
this.resizing++;
else
this.resizing = force ? 1 : 0;
if (!height)
height = dom.getInnerHeight(this.container);
if (force || size.height != height) {
size.height = height;
@@ -300,20 +313,27 @@ var VirtualRenderer = function(container, theme) {
}
}
var width = dom.getInnerWidth(this.container);
if (force || size.width != width) {
if (!width)
width = dom.getInnerWidth(this.container);
if (force || this.resizing > 1 || size.width != width) {
size.width = width;
var gutterWidth = this.showGutter ? this.$gutter.offsetWidth : 0;
this.scroller.style.left = gutterWidth + "px";
size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBar.getWidth());
this.scroller.style.width = size.scrollerWidth + "px";
this.scroller.style.right = this.scrollBar.getWidth() + "px";
if (this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
changes = changes | this.CHANGE_FULL;
}
this.$loop.schedule(changes);
if (force)
this.$renderChanges(changes, true);
else
this.$loop.schedule(changes);
if (force)
delete this.resizing;
};
/**
@@ -642,8 +662,8 @@ var VirtualRenderer = function(container, theme) {
this.scrollBar.setScrollTop(this.scrollTop);
};
this.$renderChanges = function(changes) {
if (!changes || !this.session || !this.container.offsetWidth)
this.$renderChanges = function(changes, force) {
if (!force && (!changes || !this.session || !this.container.offsetWidth))
return;
// text, scrolling and resize changes can cause the view port size to change
@@ -1,252 +0,0 @@
/*!
* jQuery throttle / debounce - v1.1 - 3/7/2010
* http://benalman.com/projects/jquery-throttle-debounce-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
// Script: jQuery throttle / debounce: Sometimes, less is more!
//
// *Version: 1.1, Last updated: 3/7/2010*
//
// Project Home - http://benalman.com/projects/jquery-throttle-debounce-plugin/
// GitHub - http://github.com/cowboy/jquery-throttle-debounce/
// Source - http://github.com/cowboy/jquery-throttle-debounce/raw/master/jquery.ba-throttle-debounce.js
// (Minified) - http://github.com/cowboy/jquery-throttle-debounce/raw/master/jquery.ba-throttle-debounce.min.js (0.7kb)
//
// About: License
//
// Copyright (c) 2010 "Cowboy" Ben Alman,
// Dual licensed under the MIT and GPL licenses.
// http://benalman.com/about/license/
//
// About: Examples
//
// These working examples, complete with fully commented code, illustrate a few
// ways in which this plugin can be used.
//
// Throttle - http://benalman.com/code/projects/jquery-throttle-debounce/examples/throttle/
// Debounce - http://benalman.com/code/projects/jquery-throttle-debounce/examples/debounce/
//
// About: Support and Testing
//
// Information about what version or versions of jQuery this plugin has been
// tested with, what browsers it has been tested in, and where the unit tests
// reside (so you can test it yourself).
//
// jQuery Versions - none, 1.3.2, 1.4.2
// Browsers Tested - Internet Explorer 6-8, Firefox 2-3.6, Safari 3-4, Chrome 4-5, Opera 9.6-10.1.
// Unit Tests - http://benalman.com/code/projects/jquery-throttle-debounce/unit/
//
// About: Release History
//
// 1.1 - (3/7/2010) Fixed a bug in <jQuery.throttle> where trailing callbacks
// executed later than they should. Reworked a fair amount of internal
// logic as well.
// 1.0 - (3/6/2010) Initial release as a stand-alone project. Migrated over
// from jquery-misc repo v0.4 to jquery-throttle repo v1.0, added the
// no_trailing throttle parameter and debounce functionality.
//
// Topic: Note for non-jQuery users
//
// jQuery isn't actually required for this plugin, because nothing internal
// uses any jQuery methods or properties. jQuery is just used as a namespace
// under which these methods can exist.
//
// Since jQuery isn't actually required for this plugin, if jQuery doesn't exist
// when this plugin is loaded, the method described below will be created in
// the `Cowboy` namespace. Usage will be exactly the same, but instead of
// $.method() or jQuery.method(), you'll need to use Cowboy.method().
(function(window,undefined){
'$:nomunge'; // Used by YUI compressor.
// Since jQuery really isn't required for this plugin, use `jQuery` as the
// namespace only if it already exists, otherwise use the `Cowboy` namespace,
// creating it if necessary.
var $ = window.jQuery || window.Cowboy || ( window.Cowboy = {} ),
// Internal method reference.
jq_throttle;
// Method: jQuery.throttle
//
// Throttle execution of a function. Especially useful for rate limiting
// execution of handlers on events like resize and scroll. If you want to
// rate-limit execution of a function to a single time, see the
// <jQuery.debounce> method.
//
// In this visualization, | is a throttled-function call and X is the actual
// callback execution:
//
// > Throttled with `no_trailing` specified as false or unspecified:
// > ||||||||||||||||||||||||| (pause) |||||||||||||||||||||||||
// > X X X X X X X X X X X X
// >
// > Throttled with `no_trailing` specified as true:
// > ||||||||||||||||||||||||| (pause) |||||||||||||||||||||||||
// > X X X X X X X X X X
//
// Usage:
//
// > var throttled = jQuery.throttle( delay, [ no_trailing, ] callback );
// >
// > jQuery('selector').bind( 'someevent', throttled );
// > jQuery('selector').unbind( 'someevent', throttled );
//
// This also works in jQuery 1.4+:
//
// > jQuery('selector').bind( 'someevent', jQuery.throttle( delay, [ no_trailing, ] callback ) );
// > jQuery('selector').unbind( 'someevent', callback );
//
// Arguments:
//
// delay - (Number) A zero-or-greater delay in milliseconds. For event
// callbacks, values around 100 or 250 (or even higher) are most useful.
// no_trailing - (Boolean) Optional, defaults to false. If no_trailing is
// true, callback will only execute every `delay` milliseconds while the
// throttled-function is being called. If no_trailing is false or
// unspecified, callback will be executed one final time after the last
// throttled-function call. (After the throttled-function has not been
// called for `delay` milliseconds, the internal counter is reset)
// callback - (Function) A function to be executed after delay milliseconds.
// The `this` context and all arguments are passed through, as-is, to
// `callback` when the throttled-function is executed.
//
// Returns:
//
// (Function) A new, throttled, function.
$.throttle = jq_throttle = function( delay, no_trailing, callback, debounce_mode ) {
// After wrapper has stopped being called, this timeout ensures that
// `callback` is executed at the proper times in `throttle` and `end`
// debounce modes.
var timeout_id,
// Keep track of the last time `callback` was executed.
last_exec = 0;
// `no_trailing` defaults to falsy.
if ( typeof no_trailing !== 'boolean' ) {
debounce_mode = callback;
callback = no_trailing;
no_trailing = undefined;
}
// The `wrapper` function encapsulates all of the throttling / debouncing
// functionality and when executed will limit the rate at which `callback`
// is executed.
function wrapper() {
var that = this,
elapsed = +new Date() - last_exec,
args = arguments;
// Execute `callback` and update the `last_exec` timestamp.
function exec() {
last_exec = +new Date();
callback.apply( that, args );
};
// If `debounce_mode` is true (at_begin) this is used to clear the flag
// to allow future `callback` executions.
function clear() {
timeout_id = undefined;
};
if ( debounce_mode && !timeout_id ) {
// Since `wrapper` is being called for the first time and
// `debounce_mode` is true (at_begin), execute `callback`.
exec();
}
// Clear any existing timeout.
timeout_id && clearTimeout( timeout_id );
if ( debounce_mode === undefined && elapsed > delay ) {
// In throttle mode, if `delay` time has been exceeded, execute
// `callback`.
exec();
} else if ( no_trailing !== true ) {
// In trailing throttle mode, since `delay` time has not been
// exceeded, schedule `callback` to execute `delay` ms after most
// recent execution.
//
// If `debounce_mode` is true (at_begin), schedule `clear` to execute
// after `delay` ms.
//
// If `debounce_mode` is false (at end), schedule `callback` to
// execute after `delay` ms.
timeout_id = setTimeout( debounce_mode ? clear : exec, debounce_mode === undefined ? delay - elapsed : delay );
}
};
// Set the guid of `wrapper` function to the same of original callback, so
// it can be removed in jQuery 1.4+ .unbind or .die by using the original
// callback as a reference.
if ( $.guid ) {
wrapper.guid = callback.guid = callback.guid || $.guid++;
}
// Return the wrapper function.
return wrapper;
};
// Method: jQuery.debounce
//
// Debounce execution of a function. Debouncing, unlike throttling,
// guarantees that a function is only executed a single time, either at the
// very beginning of a series of calls, or at the very end. If you want to
// simply rate-limit execution of a function, see the <jQuery.throttle>
// method.
//
// In this visualization, | is a debounced-function call and X is the actual
// callback execution:
//
// > Debounced with `at_begin` specified as false or unspecified:
// > ||||||||||||||||||||||||| (pause) |||||||||||||||||||||||||
// > X X
// >
// > Debounced with `at_begin` specified as true:
// > ||||||||||||||||||||||||| (pause) |||||||||||||||||||||||||
// > X X
//
// Usage:
//
// > var debounced = jQuery.debounce( delay, [ at_begin, ] callback );
// >
// > jQuery('selector').bind( 'someevent', debounced );
// > jQuery('selector').unbind( 'someevent', debounced );
//
// This also works in jQuery 1.4+:
//
// > jQuery('selector').bind( 'someevent', jQuery.debounce( delay, [ at_begin, ] callback ) );
// > jQuery('selector').unbind( 'someevent', callback );
//
// Arguments:
//
// delay - (Number) A zero-or-greater delay in milliseconds. For event
// callbacks, values around 100 or 250 (or even higher) are most useful.
// at_begin - (Boolean) Optional, defaults to false. If at_begin is false or
// unspecified, callback will only be executed `delay` milliseconds after
// the last debounced-function call. If at_begin is true, callback will be
// executed only at the first debounced-function call. (After the
// throttled-function has not been called for `delay` milliseconds, the
// internal counter is reset)
// callback - (Function) A function to be executed after delay milliseconds.
// The `this` context and all arguments are passed through, as-is, to
// `callback` when the debounced-function is executed.
//
// Returns:
//
// (Function) A new, debounced, function.
$.debounce = function( delay, at_begin, callback ) {
return callback === undefined
? jq_throttle( delay, at_begin, false )
: jq_throttle( delay, callback, at_begin !== false );
};
})(this);
@@ -0,0 +1,2 @@
(function(window,undefined){"$:nomunge";var $=window.jQuery||window.Cowboy||(window.Cowboy={}),jq_throttle;$.throttle=jq_throttle=function(delay,no_trailing,callback,debounce_mode){var timeout_id,last_exec=0;if(typeof no_trailing!=="boolean"){debounce_mode=callback;callback=no_trailing;no_trailing=undefined}function wrapper(){var that=this,elapsed=+new Date-last_exec,args=arguments;function exec(){last_exec=+new Date;callback.apply(that,args)}function clear(){timeout_id=undefined}if(debounce_mode&&
!timeout_id)exec();timeout_id&&clearTimeout(timeout_id);if(debounce_mode===undefined&&elapsed>delay)exec();else if(no_trailing!==true)timeout_id=setTimeout(debounce_mode?clear:exec,debounce_mode===undefined?delay-elapsed:delay)}if($.guid)wrapper.guid=callback.guid=callback.guid||$.guid++;return wrapper};$.debounce=function(delay,at_begin,callback){return callback===undefined?jq_throttle(delay,at_begin,false):jq_throttle(delay,callback,at_begin!==false)}})(this);
@@ -1,6 +1,7 @@
require([ 'ace/ext/static_highlight', 'ace/theme/github', 'ace/editor', 'ace/virtual_renderer', 'ace/mode/markdown', 'ace/theme/twilight',
require([ 'ace/undomanager', 'ace/ext/static_highlight', 'ace/theme/github', 'ace/editor', 'ace/virtual_renderer', 'ace/mode/markdown', 'ace/theme/twilight',
'ace/mode/c_cpp', 'ace/mode/clojure', 'ace/mode/coffee', 'ace/mode/coldfusion', 'ace/mode/csharp', 'ace/mode/css', 'ace/mode/diff', 'ace/mode/golang', 'ace/mode/groovy', 'ace/mode/haxe', 'ace/mode/html', 'ace/mode/java', 'ace/mode/javascript', 'ace/mode/json', 'ace/mode/latex', 'ace/mode/less', 'ace/mode/liquid', 'ace/mode/lua', 'ace/mode/markdown', 'ace/mode/ocaml', 'ace/mode/perl', 'ace/mode/pgsql', 'ace/mode/php', 'ace/mode/powershell', 'ace/mode/python', 'ace/mode/ruby', 'ace/mode/scad', 'ace/mode/scala', 'ace/mode/scss', 'ace/mode/sh', 'ace/mode/sql', 'ace/mode/svg', 'ace/mode/textile', 'ace/mode/text', 'ace/mode/xml', 'ace/mode/xquery', 'ace/mode/yaml'
], function() {
var UndoManager = require("ace/undomanager").UndoManager;
var Renderer = require( 'ace/virtual_renderer' ).VirtualRenderer;
var Editor = require( 'ace/editor' ).Editor;
var dom = require( 'ace/lib/dom' );
@@ -11,7 +12,6 @@ var doc = document;
win.onbeforeunload = function() { return 'Leaving Live Preview will discard all edits!' };
var converter = Markdown.getSanitizingConverter();
var editor = new Editor( new Renderer( doc.getElementById( 'editor' ) ));//ace.edit( 'editor' );
var editorSession = editor.getSession();
$.editorSession = editorSession; // for testing
@@ -35,6 +35,7 @@ win.jsm.toggleLeftRight = function() {
var MarkdownMode = require( 'ace/mode/markdown' ).Mode;
function initAce( editor, editorSession ) {
editorSession.setUndoManager(new UndoManager());
editor.setTheme( 'ace/theme/twilight' );
editorSession.setMode( new MarkdownMode() );
// Gutter shows line numbers
@@ -72,7 +73,7 @@ var create = $.key( 'create' );
var pageName = $.key( 'page' );
var pathName = $.key( 'path' );
if (pathName === 0) {
if ( pathName === 0 ) {
pathName = undefined;
}
@@ -96,11 +97,12 @@ $.save = function( commitMessage ) {
var markdown = 'markdown';
var txt = editorSession.getValue();
var msg = defaultCommitMessage();
var newLocation = location.protocol + '//' + location.host + baseUrl;
if (pathName) {
newLocation += '/' + pathName;
}
newLocation += '/' + pageName;
// if &create=true then handle create instead of edit.
@@ -224,18 +226,24 @@ function highlight( element, language ) {
// '>' and '&gt;'.
// Firefox does not support innerText.
var data = element.innerText || element.textContent;
data = data.trim();
var mode = getLang( language );
// input, mode, theme, lineStart, disableGutter
var color = staticHighlight.render( data, mode, githubTheme, 1, true );
var newDiv = doc.createElement('div');
newDiv.innerHTML = color.html;
element.parentNode.replaceChild( newDiv, element );
element.parentNode.parentNode.replaceChild( newDiv, element.parentNode );
}
var makePreviewHtml = function () {
var text = editorSession.getValue();
if ( text == undefined || text == '' ) {
previewSet( '' );
return;
}
if (text && text == oldInputText) {
return; // Input text hasn't changed.
}
@@ -244,8 +252,7 @@ var makePreviewHtml = function () {
}
var prevTime = new Date().getTime();
text = converter.makeHtml( text );
text = md_to_html( text );
// Calculate the processing time of the HTML creation.
// It's used as the delay time in the event listener.
@@ -255,7 +262,8 @@ var makePreviewHtml = function () {
// Update the text using feature detection to support IE.
// preview.innerHTML = text; // this doesn't work on IE.
previewSet( text );
MathJax.Hub.Typeset( content );
// MathJax is loaded asynchronously.
if (typeof MathJax != 'undefined') { MathJax.Hub.Typeset( content ); }
// highlight code blocks.
var codeElements = preview.getElementsByTagName( 'pre' );
@@ -266,50 +274,40 @@ var makePreviewHtml = function () {
for ( var idx = 0; idx < codeElementsLength; idx++ ) {
// highlight removes an element so 0 is always the correct index.
// Skipped tags are not removed so they must be added.
var element = codeElements[ 0 + skipped ];
var element = codeElements[ 0 + skipped ].firstChild;
if ( element == undefined ) {
skipped++;
continue;
}
var codeHTML = element.innerHTML;
// Only use pre tags marked containing code.
if ( codeHTML[ 0 ] !== '`' )
continue;
if ( codeHTML == undefined ) {
skipped++;
continue;
}
var txt = codeHTML.split( /\b/ );
// the syntax for code highlighting means all code, even one line, contains newlines.
if ( txt.length > 1 && codeHTML.match( /\n/ ) ) {
var declaredLanguage = txt[ 1 ];
var declaredLanguage = element.className.toLowerCase();
var aceMode = declaredLanguage;
// GitHub supports 'c', 'c++', 'cpp'
// which must trigger the 'c_cpp' mode in Ace.
if ( declaredLanguage === 'cpp' ) {
if ( declaredLanguage === 'c' ||
declaredLanguage === 'c++' ||
declaredLanguage === 'cpp' ) {
aceMode = 'c_cpp';
}
// '`c++'.split( /\b/ )
// ["`", "c", "++"]
if ( declaredLanguage === 'c' ) {
aceMode = 'c_cpp';
if ( txt.length > 2 && txt[ 2 ].substring( 0, 2 ) === '++' ) {
declaredLanguage += '++';
}
}
// txt[0] must be '`'
// txt[0] = '`'; txt[1] = 'ruby'
if ( txt[ 0 ] !== '`' || $.inArray( declaredLanguage, languages ) === -1 ) {
if ( $.inArray( declaredLanguage, languages ) === -1 ) {
// Unsupported language.
skipped++;
element.innerHTML = codeHTML.substring( 1 ).trim();
continue;
}
// length + 1 for the marker character.
element.innerHTML = codeHTML.substring( declaredLanguage.length + 1 ).trim();
// highlight: element
highlight( element, aceMode );
} else {
// Highlighting is not for `code` inline syntax. For example `puts "string"`.
skipped++;
element.innerHTML = codeHTML.substring( 1 ).trim();
}
}
}
@@ -330,14 +328,18 @@ var applyTimeout = function () {
timeout = setTimeout( makePreviewHtml, elapsedTime );
};
/* Load markdown from /data/page into the ace editor. */
jQuery.ajax( {
type: 'GET',
url: baseUrl + '/data/' + $.key( 'page' ),
success: function( data ) {
editorSession.setValue( data );
}
});
/* Load markdown from /data/page into the ace editor.
~-1 == false; !~-1 == true;
*/
if ( !~location.host.indexOf('github.com') ) {
jQuery.ajax( {
type: 'GET',
url: baseUrl + '/data/' + $.key( 'page' ),
success: function( data ) {
editorSession.setValue( data );
}
});
}
$( '#save' ).click( function() {
$.save();
@@ -0,0 +1,22 @@
// Define one global function that renders markdown.
(function() {
// Grab functions from emscripten
var Pointer_stringify = Module.Pointer_stringify;
var _str_to_html = Module._str_to_html;
var malloc = Module._malloc;
var realloc = Module._realloc;
var writeStringToMemory = Module.writeStringToMemory;
var allocSize = 2048;
var pointer = malloc( allocSize ) ;
window.md_to_html = function( text ) {
var textLength = text.length;
while ( textLength > allocSize ) {
allocSize <<= 1; // double
pointer = realloc( pointer, allocSize );
}
writeStringToMemory( text, pointer );
return Pointer_stringify( _str_to_html( pointer ) );
};
})();
File diff suppressed because it is too large Load Diff
@@ -1,109 +0,0 @@
(function () {
var output, Converter;
if (typeof exports === "object" && typeof require === "function") { // we're in a CommonJS (e.g. Node.js) module
output = exports;
Converter = require("./Markdown.Converter").Converter;
} else {
output = window.Markdown;
Converter = output.Converter;
}
output.getSanitizingConverter = function () {
var converter = new Converter();
converter.hooks.chain("postConversion", sanitizeHtml);
converter.hooks.chain("postConversion", balanceTags);
return converter;
}
function sanitizeHtml(html) {
return html.replace(/<[^>]*>?/gi, sanitizeTag);
}
// (tags that can be opened/closed) | (tags that stand alone)
var basic_tag_whitelist = /^(<\/?(b|blockquote|code|del|dd|dl|dt|em|h1|h2|h3|h4|h5|h6|i|kbd|li|ol|p|pre|s|sup|sub|strong|strike|ul)>|<(br|hr)\s?\/?>)$/i;
// <a href="url..." optional title>|</a>
// Make https:// ftp:// prefix optional so relative links work. <a href="page1">page one</a>
var a_white = /^(<a\shref="(((https?|ftp):\/\/|\/))?[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+"(\stitle="[^"<>]+")?\s?>|<\/a>)$/i;
// <img src="url..." optional width optional height optional alt optional title
var img_white = /^(<img\ssrc="(https?:\/\/|\/)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+"(\swidth="\d{1,3}")?(\sheight="\d{1,3}")?(\salt="[^"<>]*")?(\stitle="[^"<>]*")?\s?\/?>)$/i;
function sanitizeTag(tag) {
if (tag.match(basic_tag_whitelist) || tag.match(a_white) || tag.match(img_white))
return tag;
else
return "";
}
/// <summary>
/// attempt to balance HTML tags in the html string
/// by removing any unmatched opening or closing tags
/// IMPORTANT: we *assume* HTML has *already* been
/// sanitized and is safe/sane before balancing!
///
/// adapted from CODESNIPPET: A8591DBA-D1D3-11DE-947C-BA5556D89593
/// </summary>
function balanceTags(html) {
if (html == "")
return "";
var re = /<\/?\w+[^>]*(\s|$|>)/g;
// convert everything to lower case; this makes
// our case insensitive comparisons easier
var tags = html.toLowerCase().match(re);
// no HTML tags present? nothing to do; exit now
var tagcount = (tags || []).length;
if (tagcount == 0)
return html;
var tagname, tag;
var ignoredtags = "<p><img><br><li><hr>";
var match;
var tagpaired = [];
var tagremove = [];
var needsRemoval = false;
// loop through matched tags in forward order
for (var ctag = 0; ctag < tagcount; ctag++) {
tagname = tags[ctag].replace(/<\/?(\w+).*/, "$1");
// skip any already paired tags
// and skip tags in our ignore list; assume they're self-closed
if (tagpaired[ctag] || ignoredtags.search("<" + tagname + ">") > -1)
continue;
tag = tags[ctag];
match = -1;
if (!/^<\//.test(tag)) {
// this is an opening tag
// search forwards (next tags), look for closing tags
for (var ntag = ctag + 1; ntag < tagcount; ntag++) {
if (!tagpaired[ntag] && tags[ntag] == "</" + tagname + ">") {
match = ntag;
break;
}
}
}
if (match == -1)
needsRemoval = tagremove[ctag] = true; // mark for removal
else
tagpaired[match] = true; // mark paired
}
if (!needsRemoval)
return html;
// delete all orphaned tags from the string
var ctag = 0;
html = html.replace(re, function (match) {
var res = tagremove[ctag] ? "" : match;
ctag++;
return res;
});
return html;
}
})();
@@ -0,0 +1,35 @@
/*
RequireJS 2.0.4 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
*/
var requirejs,require,define;
(function(Y){function x(b){return J.call(b)==="[object Function]"}function G(b){return J.call(b)==="[object Array]"}function q(b,c){if(b){var e;for(e=0;e<b.length;e+=1)if(b[e]&&c(b[e],e,b))break}}function N(b,c){if(b){var e;for(e=b.length-1;e>-1;e-=1)if(b[e]&&c(b[e],e,b))break}}function y(b,c){for(var e in b)if(b.hasOwnProperty(e)&&c(b[e],e))break}function K(b,c,e,i){c&&y(c,function(c,j){if(e||!b.hasOwnProperty(j))i&&typeof c!=="string"?(b[j]||(b[j]={}),K(b[j],c,e,i)):b[j]=c});return b}function s(b,
c){return function(){return c.apply(b,arguments)}}function Z(b){if(!b)return b;var c=Y;q(b.split("."),function(b){c=c[b]});return c}function $(b,c,e){return function(){var i=fa.call(arguments,0),g;if(e&&x(g=i[i.length-1]))g.__requireJsBuild=!0;i.push(c);return b.apply(null,i)}}function aa(b,c,e){q([["toUrl"],["undef"],["defined","requireDefined"],["specified","requireSpecified"]],function(i){var g=i[1]||i[0];b[i[0]]=c?$(c[g],e):function(){var b=z[O];return b[g].apply(b,arguments)}})}function H(b,
c,e,i){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=i;if(e)c.originalError=e;return c}function ga(){if(I&&I.readyState==="interactive")return I;N(document.getElementsByTagName("script"),function(b){if(b.readyState==="interactive")return I=b});return I}var ha=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,ia=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,ba=/\.js$/,ja=/^\.\//,J=Object.prototype.toString,A=Array.prototype,fa=A.slice,ka=A.splice,w=!!(typeof window!==
"undefined"&&navigator&&document),ca=!w&&typeof importScripts!=="undefined",la=w&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,O="_",S=typeof opera!=="undefined"&&opera.toString()==="[object Opera]",z={},p={},P=[],L=!1,j,t,C,u,D,I,E,da,ea;if(typeof define==="undefined"){if(typeof requirejs!=="undefined"){if(x(requirejs))return;p=requirejs;requirejs=void 0}typeof require!=="undefined"&&!x(require)&&(p=require,require=void 0);j=requirejs=function(b,c,e,i){var g=O,r;!G(b)&&
typeof b!=="string"&&(r=b,G(c)?(b=c,c=e,e=i):b=[]);if(r&&r.context)g=r.context;(i=z[g])||(i=z[g]=j.s.newContext(g));r&&i.configure(r);return i.require(b,c,e)};j.config=function(b){return j(b)};require||(require=j);j.version="2.0.4";j.jsExtRegExp=/^\/|:|\?|\.js$/;j.isBrowser=w;A=j.s={contexts:z,newContext:function(b){function c(a,d,o){var l=d&&d.split("/"),f=l,b=k.map,c=b&&b["*"],e,g,h;if(a&&a.charAt(0)===".")if(d){f=k.pkgs[d]?l=[d]:l.slice(0,l.length-1);d=a=f.concat(a.split("/"));for(f=0;d[f];f+=
1)if(e=d[f],e===".")d.splice(f,1),f-=1;else if(e==="..")if(f===1&&(d[2]===".."||d[0]===".."))break;else f>0&&(d.splice(f-1,2),f-=2);f=k.pkgs[d=a[0]];a=a.join("/");f&&a===d+"/"+f.main&&(a=d)}else a.indexOf("./")===0&&(a=a.substring(2));if(o&&(l||c)&&b){d=a.split("/");for(f=d.length;f>0;f-=1){g=d.slice(0,f).join("/");if(l)for(e=l.length;e>0;e-=1)if(o=b[l.slice(0,e).join("/")])if(o=o[g]){h=o;break}!h&&c&&c[g]&&(h=c[g]);if(h){d.splice(0,f,h);a=d.join("/");break}}}return a}function e(a){w&&q(document.getElementsByTagName("script"),
function(d){if(d.getAttribute("data-requiremodule")===a&&d.getAttribute("data-requirecontext")===h.contextName)return d.parentNode.removeChild(d),!0})}function i(a){var d=k.paths[a];if(d&&G(d)&&d.length>1)return e(a),d.shift(),h.undef(a),h.require([a]),!0}function g(a,d,o,b){var f=a?a.indexOf("!"):-1,v=null,e=d?d.name:null,g=a,i=!0,j="",k,m;a||(i=!1,a="_@r"+(N+=1));f!==-1&&(v=a.substring(0,f),a=a.substring(f+1,a.length));v&&(v=c(v,e,b),m=n[v]);a&&(v?j=m&&m.normalize?m.normalize(a,function(a){return c(a,
e,b)}):c(a,e,b):(j=c(a,e,b),k=h.nameToUrl(j)));a=v&&!m&&!o?"_unnormalized"+(O+=1):"";return{prefix:v,name:j,parentMap:d,unnormalized:!!a,url:k,originalName:g,isDefine:i,id:(v?v+"!"+j:j)+a}}function r(a){var d=a.id,o=m[d];o||(o=m[d]=new h.Module(a));return o}function p(a,d,o){var b=a.id,f=m[b];if(n.hasOwnProperty(b)&&(!f||f.defineEmitComplete))d==="defined"&&o(n[b]);else r(a).on(d,o)}function B(a,d){var b=a.requireModules,l=!1;if(d)d(a);else if(q(b,function(d){if(d=m[d])d.error=a,d.events.error&&(l=
!0,d.emit("error",a))}),!l)j.onError(a)}function u(){P.length&&(ka.apply(F,[F.length-1,0].concat(P)),P=[])}function t(a,d,b){a=a&&a.map;d=$(b||h.require,a,d);aa(d,h,a);d.isBrowser=w;return d}function z(a){delete m[a];q(M,function(d,b){if(d.map.id===a)return M.splice(b,1),d.defined||(h.waitCount-=1),!0})}function A(a,d){var b=a.map.id,l=a.depMaps,f;if(a.inited){if(d[b])return a;d[b]=!0;q(l,function(a){if(a=m[a.id])return!a.inited||!a.enabled?(f=null,delete d[b],!0):f=A(a,K({},d))});return f}}function C(a,
d,b){var l=a.map.id,f=a.depMaps;if(a.inited&&a.map.isDefine){if(d[l])return n[l];d[l]=a;q(f,function(f){var f=f.id,c=m[f];!Q[f]&&c&&(!c.inited||!c.enabled?b[l]=!0:(c=C(c,d,b),b[f]||a.defineDepById(f,c)))});a.check(!0);return n[l]}}function D(a){a.check()}function E(){var a=k.waitSeconds*1E3,d=a&&h.startTime+a<(new Date).getTime(),b=[],l=!1,f=!0,c,g,j;if(!T){T=!0;y(m,function(a){c=a.map;g=c.id;if(a.enabled&&!a.error)if(!a.inited&&d)i(g)?l=j=!0:(b.push(g),e(g));else if(!a.inited&&a.fetched&&c.isDefine&&
(l=!0,!c.prefix))return f=!1});if(d&&b.length)return a=H("timeout","Load timeout for modules: "+b,null,b),a.contextName=h.contextName,B(a);f&&(q(M,function(a){if(!a.defined){var a=A(a,{}),d={};a&&(C(a,d,{}),y(d,D))}}),y(m,D));if((!d||j)&&l)if((w||ca)&&!U)U=setTimeout(function(){U=0;E()},50);T=!1}}function V(a){r(g(a[0],null,!0)).init(a[1],a[2])}function J(a){var a=a.currentTarget||a.srcElement,d=h.onScriptLoad;a.detachEvent&&!S?a.detachEvent("onreadystatechange",d):a.removeEventListener("load",d,
!1);d=h.onScriptError;a.detachEvent&&!S||a.removeEventListener("error",d,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}var k={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},shim:{}},m={},W={},F=[],n={},R={},N=1,O=1,M=[],T,X,h,Q,U;Q={require:function(a){return t(a)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports=n[a.map.id]={}},module:function(a){return a.module={id:a.map.id,uri:a.map.url,config:function(){return k.config&&k.config[a.map.id]||{}},exports:n[a.map.id]}}};
X=function(a){this.events=W[a.id]||{};this.map=a;this.shim=k.shim[a.id];this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};X.prototype={init:function(a,d,b,l){l=l||{};if(!this.inited){this.factory=d;if(b)this.on("error",b);else this.events.error&&(b=s(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.depMaps.rjsSkipMap=a.rjsSkipMap;this.errback=b;this.inited=!0;this.ignore=l.ignore;l.enabled||this.enabled?this.enable():this.check()}},defineDepById:function(a,
d){var b;q(this.depMaps,function(d,f){if(d.id===a)return b=f,!0});return this.defineDep(b,d)},defineDep:function(a,d){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=d)},fetch:function(){if(!this.fetched){this.fetched=!0;h.startTime=(new Date).getTime();var a=this.map;if(this.shim)t(this,!0)(this.shim.deps||[],s(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=this.map.url;R[a]||
(R[a]=!0,h.load(this.map.id,a))},check:function(a){if(this.enabled&&!this.enabling){var d=this.map.id,b=this.depExports,c=this.exports,f=this.factory,e;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(this.depCount<1&&!this.defined){if(x(f)){if(this.events.error)try{c=h.execCb(d,f,b,c)}catch(g){e=g}else c=h.execCb(d,f,b,c);if(this.map.isDefine)if((b=this.module)&&b.exports!==void 0&&b.exports!==this.exports)c=b.exports;else if(c===void 0&&this.usingExports)c=
this.exports;if(e)return e.requireMap=this.map,e.requireModules=[this.map.id],e.requireType="define",B(this.error=e)}else c=f;this.exports=c;if(this.map.isDefine&&!this.ignore&&(n[d]=c,j.onResourceLoad))j.onResourceLoad(h,this.map,this.depMaps);delete m[d];this.defined=!0;h.waitCount-=1;h.waitCount===0&&(M=[])}this.defining=!1;if(!a&&this.defined&&!this.defineEmitted)this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0}}else this.fetch()}},callPlugin:function(){var a=
this.map,d=a.id,b=g(a.prefix,null,!1,!0);p(b,"defined",s(this,function(b){var f=this.map.name,e=this.map.parentMap?this.map.parentMap.name:null;if(this.map.unnormalized){if(b.normalize&&(f=b.normalize(f,function(a){return c(a,e,!0)})||""),b=g(a.prefix+"!"+f,this.map.parentMap,!1,!0),p(b,"defined",s(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),b=m[b.id]){if(this.events.error)b.on("error",s(this,function(a){this.emit("error",a)}));b.enable()}}else f=s(this,function(a){this.init([],
function(){return a},null,{enabled:!0})}),f.error=s(this,function(a){this.inited=!0;this.error=a;a.requireModules=[d];y(m,function(a){a.map.id.indexOf(d+"_unnormalized")===0&&z(a.map.id)});B(a)}),f.fromText=function(a,d){var b=L;b&&(L=!1);r(g(a));j.exec(d);b&&(L=!0);h.completeLoad(a)},b.load(a.name,t(a.parentMap,!0,function(a,d){a.rjsSkipMap=!0;return h.require(a,d)}),f,k)}));h.enable(b,this);this.pluginMaps[b.id]=b},enable:function(){this.enabled=!0;if(!this.waitPushed)M.push(this),h.waitCount+=
1,this.waitPushed=!0;this.enabling=!0;q(this.depMaps,s(this,function(a,d){var b,c;if(typeof a==="string"){a=g(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.depMaps.rjsSkipMap);this.depMaps[d]=a;if(b=Q[a.id]){this.depExports[d]=b(this);return}this.depCount+=1;p(a,"defined",s(this,function(a){this.defineDep(d,a);this.check()}));this.errback&&p(a,"error",this.errback)}b=a.id;c=m[b];!Q[b]&&c&&!c.enabled&&h.enable(a,this)}));y(this.pluginMaps,s(this,function(a){var b=m[a.id];b&&!b.enabled&&
h.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){q(this.events[a],function(a){a(b)});a==="error"&&delete this.events[a]}};return h={config:k,contextName:b,registry:m,defined:n,urlFetched:R,waitCount:0,defQueue:F,Module:X,makeModuleMap:g,configure:function(a){a.baseUrl&&a.baseUrl.charAt(a.baseUrl.length-1)!=="/"&&(a.baseUrl+="/");var b=k.pkgs,c=k.shim,e=k.paths,f=k.map;K(k,a,!0);k.paths=K(e,a.paths,!0);if(a.map)k.map=
K(f||{},a.map,!0,!0);if(a.shim)y(a.shim,function(a,b){G(a)&&(a={deps:a});if(a.exports&&!a.exports.__buildReady)a.exports=h.makeShimExports(a.exports);c[b]=a}),k.shim=c;if(a.packages)q(a.packages,function(a){a=typeof a==="string"?{name:a}:a;b[a.name]={name:a.name,location:a.location||a.name,main:(a.main||"main").replace(ja,"").replace(ba,"")}}),k.pkgs=b;y(m,function(a,b){a.map=g(b)});if(a.deps||a.callback)h.require(a.deps||[],a.callback)},makeShimExports:function(a){var b;return typeof a==="string"?
(b=function(){return Z(a)},b.exports=a,b):function(){return a.apply(Y,arguments)}},requireDefined:function(a,b){var c=g(a,b,!1,!0).id;return n.hasOwnProperty(c)},requireSpecified:function(a,b){a=g(a,b,!1,!0).id;return n.hasOwnProperty(a)||m.hasOwnProperty(a)},require:function(a,d,c,e){var f;if(typeof a==="string"){if(x(d))return B(H("requireargs","Invalid require call"),c);if(j.get)return j.get(h,a,d);a=g(a,d,!1,!0);a=a.id;return!n.hasOwnProperty(a)?B(H("notloaded",'Module name "'+a+'" has not been loaded yet for context: '+
b)):n[a]}c&&!x(c)&&(e=c,c=void 0);d&&!x(d)&&(e=d,d=void 0);for(u();F.length;)if(f=F.shift(),f[0]===null)return B(H("mismatch","Mismatched anonymous define() module: "+f[f.length-1]));else V(f);r(g(null,e)).init(a,d,c,{enabled:!0});E();return h.require},undef:function(a){var b=g(a,null,!0),c=m[a];delete n[a];delete R[b.url];delete W[a];if(c){if(c.events.defined)W[a]=c.events;z(a)}},enable:function(a){m[a.id]&&r(a).enable()},completeLoad:function(a){var b=k.shim[a]||{},c=b.exports&&b.exports.exports,
e,f;for(u();F.length;){f=F.shift();if(f[0]===null){f[0]=a;if(e)break;e=!0}else f[0]===a&&(e=!0);V(f)}f=m[a];if(!e&&!n[a]&&f&&!f.inited)if(k.enforceDefine&&(!c||!Z(c)))if(i(a))return;else return B(H("nodefine","No define call for "+a,null,[a]));else V([a,b.deps||[],b.exports]);E()},toUrl:function(a,b){var e=a.lastIndexOf("."),g=null;e!==-1&&(g=a.substring(e,a.length),a=a.substring(0,e));return h.nameToUrl(c(a,b&&b.id,!0),g)},nameToUrl:function(a,b){var c,e,f,g,h,i;if(j.jsExtRegExp.test(a))g=a+(b||
"");else{c=k.paths;e=k.pkgs;g=a.split("/");for(h=g.length;h>0;h-=1)if(i=g.slice(0,h).join("/"),f=e[i],i=c[i]){G(i)&&(i=i[0]);g.splice(0,h,i);break}else if(f){c=a===f.name?f.location+"/"+f.main:f.location;g.splice(0,h,c);break}g=g.join("/")+(b||".js");g=(g.charAt(0)==="/"||g.match(/^[\w\+\.\-]+:/)?"":k.baseUrl)+g}return k.urlArgs?g+((g.indexOf("?")===-1?"?":"&")+k.urlArgs):g},load:function(a,b){j.load(h,a,b)},execCb:function(a,b,c,e){return b.apply(e,c)},onScriptLoad:function(a){if(a.type==="load"||
la.test((a.currentTarget||a.srcElement).readyState))I=null,a=J(a),h.completeLoad(a.id)},onScriptError:function(a){var b=J(a);if(!i(b.id))return B(H("scripterror","Script error",a,[b.id]))}}}};j({});aa(j);if(w&&(t=A.head=document.getElementsByTagName("head")[0],C=document.getElementsByTagName("base")[0]))t=A.head=C.parentNode;j.onError=function(b){throw b;};j.load=function(b,c,e){var i=b&&b.config||{},g;if(w)return g=i.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"),
g.type=i.scriptType||"text/javascript",g.charset="utf-8",g.async=!0,g.setAttribute("data-requirecontext",b.contextName),g.setAttribute("data-requiremodule",c),g.attachEvent&&!(g.attachEvent.toString&&g.attachEvent.toString().indexOf("[native code")<0)&&!S?(L=!0,g.attachEvent("onreadystatechange",b.onScriptLoad)):(g.addEventListener("load",b.onScriptLoad,!1),g.addEventListener("error",b.onScriptError,!1)),g.src=e,E=g,C?t.insertBefore(g,C):t.appendChild(g),E=null,g;else ca&&(importScripts(e),b.completeLoad(c))};
w&&N(document.getElementsByTagName("script"),function(b){if(!t)t=b.parentNode;if(u=b.getAttribute("data-main")){if(!p.baseUrl)D=u.split("/"),da=D.pop(),ea=D.length?D.join("/")+"/":"./",p.baseUrl=ea,u=da;u=u.replace(ba,"");p.deps=p.deps?p.deps.concat(u):[u];return!0}});define=function(b,c,e){var i,g;typeof b!=="string"&&(e=c,c=b,b=null);G(c)||(e=c,c=[]);!c.length&&x(e)&&e.length&&(e.toString().replace(ha,"").replace(ia,function(b,e){c.push(e)}),c=(e.length===1?["require"]:["require","exports","module"]).concat(c));
if(L&&(i=E||ga()))b||(b=i.getAttribute("data-requiremodule")),g=z[i.getAttribute("data-requirecontext")];(g?g.defQueue:P).push([b,c,e])};define.amd={jQuery:!0};j.exec=function(b){return eval(b)};j(p)}})(this);
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -1,32 +0,0 @@
A javascript port of Markdown, as used on Stack Overflow
and the rest of Stack Exchange network.
Largely based on showdown.js by John Fraser (Attacklab).
Original Markdown Copyright (c) 2004-2005 John Gruber
<http://daringfireball.net/projects/markdown/>
Original Showdown code copyright (c) 2007 John Fraser
Modifications and bugfixes (c) 2009 Dana Robinson
Modifications and bugfixes (c) 2009-2011 Stack Exchange Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@@ -0,0 +1,4 @@
License
Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -1,6 +1,5 @@
Client side live preview of Markdown for Gollum with syntax highlighting.
[Click for demo.](http://bootstraponline.github.com/livepreview/public)
- [sundown + livepreview](http://bootstraponline.github.com/livepreview/public)
- [markdowndeep + livepreview](http://bootstraponline.github.com/livepreview/public/index_deep.html)
Uses code/assets from:
@@ -9,13 +8,25 @@ Uses code/assets from:
0. [jquery](https://github.com/jquery/jquery)
0. [sizzle](https://github.com/jquery/sizzle)
0. [notepages](https://github.com/fivesixty/notepages)
0. [pagedown](https://code.google.com/p/pagedown/)
0. [retina_display_icon_set](http://blog.twg.ca/2010/11/retina-display-icon-set/)
0. [debounce](https://github.com/cowboy/jquery-throttle-debounce)
0. [requirejs](https://github.com/jrburke/requirejs)
0. [emscripten](https://github.com/kripken/emscripten)
0. [sundown](https://github.com/bootstraponline/sundown)
0. [markdowndeep](https://github.com/toptensoftware/markdowndeep)
See licenses folder for details.
# Updating gollum
- /public/css/custom.css (not css/gollum/)
- /public/images/*
- /public/js/*
- /public/licenses/*
- /public/index.html
- readme.md
- replace template.css link in index.html
# Dependency Notes
## Ace
@@ -31,21 +42,3 @@ All changes to Ace for livepreview have been upstreamed.
Using jQuery v1.7.2.
- Download latest production version from [jquery.com](http://www.jquery.com).
## Pagedown
The [Pagedown code](https://code.google.com/p/pagedown/source/list) used is from revision `3151a581819f39123b0b5fd1ca9e26cebdcaa873`, May 31, 2012. Markdown.Converter.js has been enhanced to support Gollum style code highlighting. Markdown.Sanitizer.js has been fixed to not remove h4-6.
https://code.google.com/p/pagedown/source/detail?r=3151a581819f39123b0b5fd1ca9e26cebdcaa873
- The h4-6 fix has been submitted for upstream inclusion. [#29](https://code.google.com/p/pagedown/issues/detail?id=29)
- livepreview has various additions to pagedown so it can't be replaced by upstream unpatched.
# Updating gollum
- /public/css/custom.css (not css/gollum/)
- /public/images/*
- /public/js/*
- /public/licenses/*
- /public/index.html
- readme.md
- replace template.css link in index.html
@@ -88,7 +88,7 @@
</div>
</div>
<textarea id="gollum-editor-body"
data-markup-lang="{{format}}" name="content">{{content}}</textarea>
data-markup-lang="{{format}}" name="content" class="mousetrap">{{content}}</textarea>
{{#header}}
<div id="gollum-editor-edit-header" class="collapsed">
@@ -14,9 +14,6 @@
<li class="minibutton">
<a href="{{base_url}}" class="action-edit-page">Home</a>
</li>
<li class="minibutton" class="jaws">
<a href="#" id="minibutton-new-page">New Page</a>
</li>
</ul>
</div>
+10 -4
View File
@@ -6,19 +6,25 @@
<link rel="stylesheet" type="text/css" href="{{base_url}}css/editor.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}css/dialog.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}css/template.css" media="all">
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="{{base_url}}css/ie7.css" media="all">
<![endif]-->
<script>var baseUrl = '{{base_url}}'</script>
<script type="text/javascript" src="{{base_url}}javascript/jquery.js"></script>
<script type="text/javascript" src="{{base_url}}javascript/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="{{base_url}}javascript/mousetrap.min.js"></script>
<script type="text/javascript" src="{{base_url}}javascript/gollum.js"></script>
<script type="text/javascript" src="{{base_url}}javascript/gollum.dialog.js"></script>
<script type="text/javascript" src="{{base_url}}javascript/gollum.placeholder.js"></script>
<script type="text/javascript" src="{{base_url}}javascript/editor/gollum.editor.js"></script>
{{#mathjax}}<script type="text/javascript" src="https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>{{/mathjax}}
{{#mathjax}}<script>(function(d,j){
j = d.createElement('script');
j.src = 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
(d.head || d.getElementsByTagName('head')[0]).appendChild(j);
}(document));
</script>{{/mathjax}}
<title>{{title}}</title>
</head>
<body>
+10 -5
View File
@@ -6,17 +6,19 @@
{{>searchbar}}
</li>
<li class="minibutton"><a href="{{base_url}}pages"
class="action-all-pages">All Pages</a></li>
class="action-all-pages">All</a></li>
<li class="minibutton"><a href="{{base_url}}fileview"
class="action-all-pages">File View</a></li>
class="action-all-pages">Files</a></li>
<li class="minibutton" class="jaws">
<a href="#" id="minibutton-new-page">New Page</a></li>
<a href="#" id="minibutton-new-page">New</a></li>
<li class="minibutton" class="jaws">
<a href="#" id="minibutton-rename-page">Rename</a></li>
{{#editable}}
<li class="minibutton"><a href="{{base_url}}edit/{{escaped_url_path}}"
class="action-edit-page">Edit Page</a></li>
class="action-edit-page">Edit</a></li>
{{/editable}}
<li class="minibutton"><a href="{{base_url}}history/{{escaped_url_path}}"
class="action-page-history">Page History</a></li>
class="action-page-history">History</a></li>
</ul>
</div>
<div id="wiki-content">
@@ -57,5 +59,8 @@
</div>
<div id="footer">
<p id="last-edit">Last edited by <b>{{author}}</b>, {{date}}</p>
<p>
<a id="delete-link" href="{{escaped_url_path}}" data-confirm="Are you sure you want to delete this page?"><span>Delete this Page</span></a>
</p>
</div>
</div>
+2 -2
View File
@@ -17,8 +17,8 @@ module Precious
:id7 => v.id[0..6],
:num => i,
:selected => @page.version.id == v.id,
:author => v.author.name,
:message => v.message,
: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.committed_date.strftime("%B %d, %Y"),
:gravatar => Digest::MD5.hexdigest(v.author.email) }
end
+1 -1
View File
@@ -15,7 +15,7 @@ module Precious
page_versions = @page.versions
first = page_versions ? page_versions.first : false
return DEFAULT_AUTHOR unless first
first.author.name
first.author.name.respond_to?(:force_encoding) ? first.author.name.force_encoding('UTF-8') : first.author.name
end
def date
+4 -16
View File
@@ -124,30 +124,17 @@ module Gollum
#
# Returns the placeholder'd String data.
def extract_tex(data)
# Random string to escape the `$` character (might be overkill)
esc = "/%%/"
data.gsub(/\\\[\s*(.*?)\s*\\\]/m) do
tag = CGI.escapeHTML($1)
id = Digest::SHA1.hexdigest(tag)
@texmap[id] = [:block, tag]
id
end.gsub(/'\$/, esc). # Replace `'$` with the `esc` string in order to escape it
gsub(/\$\$\s*(.*?)\s*\$\$/m) do
tag = CGI.escapeHTML($1)
id = Digest::SHA1.hexdigest(tag)
@texmap[id] = [:block, tag]
id
end.gsub(/\\\(\s*(.*?)\s*\\\)/m) do
tag = CGI.escapeHTML($1)
id = Digest::SHA1.hexdigest(tag)
@texmap[id] = [:inline, tag]
id
end.gsub(/\$\s*(.*?)\s*\$/m) do # match inline $<formula>$
tag = CGI.escapeHTML($1)
id = Digest::SHA1.hexdigest(tag)
@texmap[id] = [:inline, tag]
id
end.gsub(/#{esc}/, '$') # replace the `esc` string back to `$`
end
end
# Process all TeX from the texmap and replace the placeholders with the
@@ -472,11 +459,12 @@ module Gollum
# Returns the placeholder'd String data.
def extract_code(data)
data.gsub!(/^([ \t]*)``` ?([^\r\n]+)?\r?\n(.+?)\r?\n\1```\r?$/m) do
id = Digest::SHA1.hexdigest("#{$2}.#{$3}")
lang = $2 ? $2.strip : nil
id = Digest::SHA1.hexdigest("#{lang}.#{$3}")
cached = check_cache(:code, id)
@codemap[id] = cached ?
{ :output => cached } :
{ :lang => $2, :code => $3, :indent => $1 }
{ :lang => lang, :code => $3, :indent => $1 }
"#{$1}#{id}" # print the SHA1 ID with the proper indentation
end
data
+12 -3
View File
@@ -259,6 +259,13 @@ module Gollum
end
end
# Public: The first 7 characters of the current version.
#
# Returns the first 7 characters of the current version.
def version_short
version.to_s[0,7]
end
# Public: The header Page.
#
# Returns the header Page or nil if none exists.
@@ -433,8 +440,10 @@ module Gollum
false
end
# Loads a sub page. Sub page nanes (footers) are prefixed with
# an underscore to distinguish them from other Pages.
# Loads a sub page. Sub page names (footers, headers, sidebars) are prefixed with
# an underscore to distinguish them from other Pages. If there is not one within
# the current directory, starts walking up the directory tree to try and find one
# within parent directories.
#
# name - String page name.
#
@@ -447,7 +456,7 @@ module Gollum
dirs = self.path.split('/')
dirs.pop
map = @wiki.tree_map_for(@wiki.ref)
map = @wiki.tree_map_for(@wiki.ref, true)
while !dirs.empty?
if page = find_page_in_tree(map, name, dirs.join('/'))
page.parent_page = self
+8 -2
View File
@@ -682,10 +682,16 @@ module Gollum
# listing is cached based on its actual commit SHA.
#
# ref - A String ref that is either a commit SHA or references one.
# ignore_page_file_dir - Boolean, if true, searches all files within the git repo, regardless of dir/subdir
#
# Returns an Array of BlobEntry instances.
def tree_map_for(ref)
@access.tree(ref)
def tree_map_for(ref, ignore_page_file_dir=false)
if ignore_page_file_dir && !@page_file_dir.nil?
@root_access ||= GitAccess.new(path, nil, @repo_is_bare)
@root_access.tree(ref)
else
@access.tree(ref)
end
rescue Grit::GitRuby::Repository::NoSuchShaFound
[]
end
+2
View File
@@ -3,3 +3,5 @@
a8ad3c09dd842a3517085bfadd37718856dee813 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 Arran Cudbard-Bell <a.cudbardb@freeradius.org> 1309107565 +0200 commit: Test out whitespace with Sam
1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 b16b3d9fad9d78e5a669e7f33d94c96da374eccd kristi <kristi.dev@gmail.com> 1336983525 -0700 push
b16b3d9fad9d78e5a669e7f33d94c96da374eccd b0de6e794dfdc7ef3400e894225bfe23308aae5c kristi <kristi.dev@gmail.com> 1336984025 -0700 push
b0de6e794dfdc7ef3400e894225bfe23308aae5c cfea406f5f77afc7fb673a43e97721234385b1bd Darren Oakley <daz.oakley@gmail.com> 1341830099 +0100 push
cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc2 Darren Oakley <daz.oakley@gmail.com> 1341830833 +0100 push
@@ -3,3 +3,5 @@
a8ad3c09dd842a3517085bfadd37718856dee813 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 Arran Cudbard-Bell <a.cudbardb@freeradius.org> 1309107565 +0200 commit: Test out whitespace with Sam
1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 b16b3d9fad9d78e5a669e7f33d94c96da374eccd kristi <kristi.dev@gmail.com> 1336983525 -0700 push
b16b3d9fad9d78e5a669e7f33d94c96da374eccd b0de6e794dfdc7ef3400e894225bfe23308aae5c kristi <kristi.dev@gmail.com> 1336984025 -0700 push
b0de6e794dfdc7ef3400e894225bfe23308aae5c cfea406f5f77afc7fb673a43e97721234385b1bd Darren Oakley <daz.oakley@gmail.com> 1341830099 +0100 push
cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc2 Darren Oakley <daz.oakley@gmail.com> 1341830833 +0100 push

Some files were not shown because too many files have changed in this diff Show More