-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using codemirror #21
Comments
Authentic theme already includes CodeMirror for textarea fields, however file type is not detected to provide correct syntax highlighting. I'll work on file type recognition. |
Is there a such functionality? I could include it! |
I dunno, I never used CodeMirror, I'll RTFM to figure it out :) |
Well CodeMirror manual says that there're some methods to "tell" which syntax is used: <script src="lib/codemirror.js"></script>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="mode/javascript/javascript.js"></script> var myCodeMirror = CodeMirror(document.body, {
value: "function myScript(){return 100;}\n",
mode: "javascript"
}); or require([
"cm/lib/codemirror", "cm/mode/htmlmixed/htmlmixed"
], function(CodeMirror) {
CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
mode: "htmlmixed"
});
}); Any way you'll have to inlcude additional files for this. All supported modes are listed here: https://github.com/codemirror/CodeMirror/tree/master/mode |
Additional work? I could add all of those filetype-highlights to the distro? They are very small in size. |
Yeah, maybe add some code on CodeMirror init like pabloko suggested CodeMirror.modeURL = "unauthenticated/codemirror/mode/%N/%N.js"; and then in Authentic's default.min.js var e=CodeMirror.fromTextArea(g,{mode:$.urlParam('cm_mode'),... where urlParam is like $.urlParam = function(name){
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || 0;
} And I will add edit_file.cgi?file=myscript.js&path=/home/realgecko/public_html/js&cm_mode=javascript |
OK, will add it to my todo. Thanks! |
my code tries to determine syntax by file extension, if there arent results, it tries to guess the syntax... noticed sorting by file size isnt working properly there are modules for datatable jQuery.fn.dataTable.ext.type.order['file-size-pre'] = function ( data ) {
var units = data.replace(/(<([^>]+)>)/ig,"").replace(" ", "").replace( /[\d\.]/g, '' ).toLowerCase();
var multiplier = 1;
if ( units === 'kb' ) {
multiplier = 1000;
} else if ( units === 'k' ) {
multiplier = 1000;
} else if ( units === 'mb' ) {
multiplier = 1000000;
} else if ( units === 'm' ) {
multiplier = 1000000;
} else if ( units === 'gb' ) {
multiplier = 1000000000;
} else if ( units === 'g' ) {
multiplier = 1000000000;
} else if ( units === 'tb' ) {
multiplier = 1000000000000;
} else if ( units === 't' ) {
multiplier = 1000000000000;
}
console.log("data = "+data.replace(/(<([^>]+)>)/ig,"")+" mult: "+parseFloat( data.replace(/(<([^>]+)>)/ig,"") ) * multiplier+" unit: "+units);
return parseFloat( data.replace(/(<([^>]+)>)/ig,"") ) * multiplier;
}; regards |
@pabloko I made file size work in Authentic Theme. You can check it. I made it work with the following units |
@qooob fancy stuff, will try it for sure :) |
Shall we try to add content of |
@Real-Gecko Yes, just let's call it |
@qooob can you add this to theme? |
Yes, if it works and doesn't break anything - I will! Just maybe worth adding all modes there in one file. The size is very small? Or better to load on demand? |
I can't test this right now as well. Probably by the end of September I will get back to heavy development. So far only bug fixes. Just beautify current |
Ok, I'll try as soon as I have some time. |
Well ive using it since installed without any problems or issues, but tbh dont mind me im a noob here, just discovered webmin and needed to do some specific things. @qooob thanks for the snip |
Well Webmin is great, but it's interface API is a little outdated. That's why we are here trying to solve all those issues, to make Webmin even better :) |
@Real-Gecko and @pabloko and @Zen4All Guys, if I add to How does it sound? |
Yep, that will be nice :) |
Will release updated version 14 with new features soon and mention your beautiful project on changelog, so people would know. I'll be on ICQ today. |
OK, guys. Please update Filemin, as people already asking where the CodeHighligh went away. Authentic Theme Version 14 has no code highlight for Filemin. Modes you need you will find in js/codemirror/modes folder. |
This is super cool! You guys are awesome. |
I've tried to use Codemirror's modes shipped with Authentic 14, but I could not make things work, maybe tis because each mode file has |
Actually, nothing stop you from shipping it. And I thinks it will be the right way. What do you think? If you agree I would actually like to remove it from the theme distro? |
Yeah, I will ship it with the module, it's better not to overload your theme :) |
Alright, superb! ;) |
Well, I must apologize! Authentic Theme will fully support FIlemin and you don't have to worry about it!! I just realized how COOL it is to use |
Version 14.01 - will have it all!! |
Nice, then I'll rollback my changes :) |
I AM SORRY!!!!! |
I'ts OK :) |
Please update to test version 14.01, has better support for Filemin! |
Fixed in 0.9.4. |
I needed to add some syntax highligter to the file editor, so added codemirror to the project, just clone the codemirror git on unauthenticated/codemirror and do these changes:
file_editor.cgi
unauthenticated/js/cmauto.js
It will try to detect the markup to use by file name or guessing it if fails. needed to use HTML:Entities to fix some bugs when displaying some codes. Also have auto growing.
The question is, why the hell is not this module by default on webmin??
The text was updated successfully, but these errors were encountered: