From 8645927cbcf2e8119ffd93c57f9fa266896ca476 Mon Sep 17 00:00:00 2001 From: Eston Bond Date: Wed, 3 Nov 2010 15:00:20 -0700 Subject: [PATCH] Adding textile definition --- scratch/TODO | 15 ++- scratch/js/gollum-editor/langs/textile.js | 111 ++++++++++++++++++++++ 2 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 scratch/js/gollum-editor/langs/textile.js diff --git a/scratch/TODO b/scratch/TODO index 742577df..553a390e 100644 --- a/scratch/TODO +++ b/scratch/TODO @@ -1,5 +1,10 @@ -Create Common Layout -Create Basic CSS -Create View Page -Create History Page -Create Edit Page \ No newline at end of file +Gollum Editor + - Style / Generate dialogs + - Dynamically show/hide different function bar buttons based on active language capabilities + - Def: Org + - Def: Pod + - Def: RDoc + - Def: Restructured Text + +Make function bar button sprite +Roll scratch/ design into Mustache \ No newline at end of file diff --git a/scratch/js/gollum-editor/langs/textile.js b/scratch/js/gollum-editor/langs/textile.js new file mode 100644 index 00000000..961ad247 --- /dev/null +++ b/scratch/js/gollum-editor/langs/textile.js @@ -0,0 +1,111 @@ +/** + * Textile Language Definition + */ +(function() { + +var Textile = { + + 'function-bold' : { + search: /([^\n]+)([\n]*)/gi, + replace: "*$1*$2" + }, + + 'function-italic' : { + search: /([^\n]+)([\n]*)/gi, + replace: "_$1_$2" + }, + + 'function-hr' : { + append: "\n***\n" + }, + + 'function-code' : { + search: /([^\n]+)([\n]*)/gi, + replace: "
$1
$2" + }, + + 'function-ul' : { + search: /(.+)([\n]?)/gi, + replace: "* $1$2" + }, + + /* This looks silly but is completely valid Markdown */ + 'function-ol' : { + search: /(.+)([\n]?)/gi, + replace: "# $1$2" + }, + + 'function-blockquote' : { + search: /(.+)([\n]?)/gi, + replace: "bq. $1$2" + }, + + 'function-link' : { + exec: function( txt, selText, $field ) { + var results = null; + $.GollumEditor.Dialog({ + title: 'Insert Link', + fields: [ + { + id: 'text', + name: 'Link Text', + type: 'text', + help: 'The text to display to the user.' + }, + { + id: 'href', + name: 'URL', + type: 'text', + help: 'The URL to link to.' + } + ], + OK: function( res ) { + if ( res['text'] && res['href'] ) { + return '"' + res['text'] + '":' + + res['href']; + } + else + return ''; + } + }); + + + } + }, + + 'function-image' : { + exec: function( txt, selText, $field ) { + var results = null; + $.GollumEditor.Dialog.init({ + title: 'Insert Image', + fields: [ + { + id: 'url', + name: 'Image URL', + type: 'text' + }, + { + id: 'alt', + name: 'Alt Text', + type: 'text' + } + ], + OK: function( res ) { + if ( res['url'] ) { + var h = '!' + res['url']; + if ( res['alt'] != '' ) { + h += '(' + res['alt'] + ')'; + } + h += '!'; + return h; + } + } + }); + } + } + +}; + +jQuery.GollumEditor.defineLanguage('markdown', Textile); + +})();