Skip to content

Commit

Permalink
Merge pull request #17 from turnermm/geshi
Browse files Browse the repository at this point in the history
Geshi
  • Loading branch information
turnermm committed May 10, 2017
2 parents 2de53b6 + f38eaa4 commit d53f6ad
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 143 deletions.
26 changes: 25 additions & 1 deletion action/meta.php
Expand Up @@ -99,7 +99,31 @@ function _ajax_call(Doku_Event $event, $param) {
return;
}

if ($event->data !== 'refresh_save') {

if ($event->data == 'geshi_sel') { //get geshi file names , return as ;; separated string w/o php extensions
$event->stopPropagation();
$event->preventDefault();
$gdir = '/var/www/html/devel/vendor/easybook/geshi/geshi/';
if( class_exists('GeSHi')) {
if(defined('GESHI_LANG_ROOT') ) $geshi_dir =GESHI_LANG_ROOT;
}
else {
echo "ENotfound\n";
return ;
}
$gfiles = scandir ($geshi_dir);
$selects = array();
foreach($gfiles as $gfile){
if(is_dir($gfile)) continue;
$gfile = preg_replace("/\.php\n?$/","",$gfile);
$selects[] = $gfile;
}
$selects = implode ( ';;', $selects );
echo $selects;
return;
}

if ($event->data !== 'refresh_save') { // save ckgedit backups in native dw format
return;
}

Expand Down
3 changes: 3 additions & 0 deletions ckeditor/Changes
Expand Up @@ -3,3 +3,6 @@ rev_17-Jan_30-08_40
30 Jan 2017
Synched with ckgedit

May 5
Synched geshi update to ckgedit

2 changes: 1 addition & 1 deletion ckeditor/config.js

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions ckeditor/config.js.unc
Expand Up @@ -231,6 +231,32 @@ var get_ckgdokuor_version = function() {
'html'
);
}

var SelectOptions = function() {
var retv;
config.jquery.ajax(
top.DOKU_BASE + '/lib/exe/ajax.php',
{
data:
{
call: 'geshi_sel'
},
type: "GET",
dataType: "html",
success: function(data, textStatus, jqXHR)
{
config.geshi_opts = data;
},
error: function(jqXHR, textStatus, errorThrown )
{
alert(textStatus);
alert(errorThrown);
}
}
);
// return retv;
};
SelectOptions();
config.filebrowserWindowWidth='60%';
config.filebrowserWindowHeight = '60%';
//config.filebrowserWindowFeatures = 'location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes,scrollbars=yes,left=20';
Expand Down
139 changes: 1 addition & 138 deletions ckeditor/plugins/geshi/dialogs/geshi.js 100755 → 100644

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

176 changes: 176 additions & 0 deletions ckeditor/plugins/geshi/dialogs/geshi.js.unc
@@ -0,0 +1,176 @@
/**
* Copyright (c) 2014-2016, CKSource - Frederico Knabben. All rights reserved.
* Licensed under the terms of the MIT License (see LICENSE.md).
*
* The abbr plugin dialog window definition.
*
* Created out of the CKEditor Plugin SDK:
* http://docs.ckeditor.com/#!/guide/plugin_sdk_sample_1
*/

// Our dialog definition.
CKEDITOR.dialog.add( 'geshiDialog', function( editor ) {
var radio, ckg_geshi_langopts = new Array();
var href, id,geshi_dialog, t_display,s_display;

var getHref = function() {
var data = window.location.pathname;
var qs = window.location.search;
var matches = data.match(/\/(.*?)\/(doku.php)?\/?(.*)/);

if(qs_match = qs.match(/id=([\w:_\.]+)\b/)) { //none
id = qs_match[1];
href = matches[0];
}
else if(!matches[2])
{
id = matches[3];
href = matches[1] + '/doku.php';
}
else {
id = matches[3];
href = matches[2] + '/doku.php';
}
if(!href) href='doku.php';
if(!id) id = 'start';
return {'href':href, 'id':id};
};

var downloadable_header = function(type,fname) {
var id = 'start';
var file = fname ? fname: 'temp.' + type;
var href_vals = getHref();
return '<dl class="file">'
+'<dt><a href="' + href_vals.href + '?do=export_code&id=' + href_vals.id+ '&codeblock=0" title="Download Snippet" class="mediafile mf_' + type +'">' +file +'</a></dt> <dd><pre class="file ' + type+ '">';
};

var downloadable_footer = function() {
return "</pre> </dd></dl>";
}

ckg_geshi_langopts = editor.config.geshi_opts;
if(!ckg_geshi_langopts.match(/ENotfound/)) {
ckg_geshi_langopts = ckg_geshi_langopts.split(';;');
var tmp;
for(var i=0; i<ckg_geshi_langopts.length; i++) {
tmp = ckg_geshi_langopts[i] ;
ckg_geshi_langopts[i] = new Array(tmp);
}
ckg_geshi_langopts.unshift(['Not Set']);
s_display = 'display:block';
t_display = 'display:none';
}
else {
t_display = 'display:inline';
s_display = 'display:none';
ckg_geshi_langopts = [];
}
return {

// Basic properties of the dialog window: title, minimum size.
title: 'Abbreviation Properties',
minWidth: 600,
minHeight: 350,

// Dialog window content definition.
contents: [
{
// Definition of the Basic Settings dialog tab (page).
id: 'tab-basic',
label: 'Basic Settings',

// The tab content.
elements: [
{
// Text input field for the abbreviation text.
type: 'textarea',
rows:18,
cols: 80,
id: 'geshi',
label: editor.lang.geshi.code,
// Validation checking whether the field is not empty.
validate: CKEDITOR.dialog.validate.notEmpty(editor.lang.geshi.code_empty)
},
{
type: 'hbox',
widths: [ '33%', '33%','33%'],
children: [
{
type: 'select',
id: 'ckg_geshi_lang',
label: editor.lang.geshi.lang,
items: ckg_geshi_langopts,
'default':ckg_geshi_langopts[0],
style: s_display,
onChange: function( api ) {
geshi_dialog.getContentElement( 'tab-basic', 'language' ).setValue(this.getValue());
}
},

{
type: 'text',
id: 'language',
style: t_display,
label: editor.lang.geshi.lang || 'Programming Language',
width: '175px',
validate: CKEDITOR.dialog.validate.notEmpty(editor.lang.geshi.lang_empty)
},
{
type: 'text',
id: 'file',
label: editor.lang.geshi.file || 'File name',
width: '175px',
},
{
type: 'radio',
id: 'which',
label: editor.lang.geshi.which,
items: [ [ editor.lang.geshi.codeblock, 'block' ], [ editor.lang.geshi.snippet, 'snippet' ] ],
'default': 'block',
style: 'color: green',
onClick: function() {
radio = this.getValue();
}
},
] //hbox children
}, //hbox

] //elements
}, //contents

], //contents

onShow : function()
{
var dialog = this;
geshi_dialog = dialog;
selection = editor.getSelection();
var text = selection.getSelectedText();
dialog.getContentElement( 'tab-basic', 'geshi' ).setValue( text );
// dialog.getContentElement( 'tab-basic', 'language' ).style='display:block';
// alert( 'Current value: ' + dialog.getValueOf( 'tab-basic', 'ckg_geshi_lang' ) );
},

// This method is invoked once a user clicks the OK button, confirming the dialog.
onOk: function() {

// The context of this function is the dialog object itself.
// http://docs.ckeditor.com/#!/api/CKEDITOR.dialog

var dialog = this, retval;
var text = dialog.getValueOf( 'tab-basic', 'geshi' );
var which = dialog.getValueOf( 'tab-basic', 'which' );
//dialog.getValueOf( 'tab-basic', 'language');
var p_lang = dialog.getValueOf( 'tab-basic', 'ckg_geshi_lang' );
if(!p_lang) p_lang = dialog.getValueOf( 'tab-basic', 'language' );
if(!p_lang) return;

if(which == 'block') {
retval = '<pre class="code ' + p_lang + ' ">' + text + '</pre>';
}
else retval = downloadable_header(p_lang,dialog.getValueOf( 'tab-basic', 'file' ) ) + text + downloadable_footer();
editor.insertHtml(retval);

}
};
});
2 changes: 1 addition & 1 deletion conf/metadata.php
Expand Up @@ -17,7 +17,7 @@
$meta['auth_ci'] = array('onoff');
$meta['nix_style'] = array('onoff');
$meta['no_symlinks'] = array('onoff');
$meta['direction'] = array('multichoice','_choices' => array('nocheck','dokuwiki','ltr','rtl'));#
$meta['direction'] = array('multichoice','_choices' => array('nocheck','dokuwiki','ltr','rtl'));
$meta['scayt_auto'] = array('multichoice','_choices' => array('on','off'));
$meta['scayt_lang'] = array('multichoice','_choices' => array('American English/en_US','Brazilian Portuguese/pt_BR','British English/en_GB','Canadian English/en_CA','Canadian French/fr_CA','Danish/da_DK','Dutch/nl_NL','Finnish/fi_FI','French/fr_FR','German/de_DE','Greek/el_GR','Italian/it_IT', 'Norwegian/nb_NO','Portuguese/pt_PT', 'Spanish/es_ES','Swedish/sv_SE'));
$meta['complex_tables'] = array('onoff');
Expand Down

0 comments on commit d53f6ad

Please sign in to comment.