mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-13 08:46:09 +01:00
codemirror: perl support
This commit is contained in:
@@ -11,7 +11,7 @@ from filemanager.models import Trash
|
||||
|
||||
class FileManager:
|
||||
modes = {'php': 'application/x-httpd-php', 'javascript': 'javascript', 'python': 'text/x-python',
|
||||
'html': 'text/html', 'go': 'text/x-go', 'css': 'text/css', 'java': 'text/x-java'}
|
||||
'html': 'text/html', 'go': 'text/x-go', 'css': 'text/css', 'java': 'text/x-java', 'perl': 'text/x-perl'}
|
||||
|
||||
def __init__(self, request, data):
|
||||
self.request = request
|
||||
@@ -31,8 +31,12 @@ class FileManager:
|
||||
return FileManager.modes['go']
|
||||
elif fileName.endswith('.css') or fileName.endswith('.scss'):
|
||||
return FileManager.modes['css']
|
||||
elif fileName.endswith('.pl') or fileName.endswith('.PL'):
|
||||
return FileManager.modes['perl']
|
||||
elif fileName.endswith('.java'):
|
||||
return FileManager.modes['java']
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
@staticmethod
|
||||
@@ -117,6 +121,11 @@ class FileManager:
|
||||
return """
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.58.1/mode/clike/clike.min.js" integrity="sha512-HT3t3u7HfQ7USbSZa0Tk5caEnUfO8s58OWqMBwm96xaZAbA17rpnXXHDefR8ixVmSSVssbOv3W3OMh6mNX/XuQ==" crossorigin="anonymous"></script>
|
||||
"""
|
||||
elif mode == FileManager.modes['perl']:
|
||||
return """
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.58.1/mode/perl/perl.min.js" integrity="sha512-6rKFA1mIjmFqxMM/b0dtjQOWFRAoqKCmhb7/6u2KohJcP4poKbrUI08Yf5GXsK+rkCr2dQnppV7gMe2a0HGQBQ==" crossorigin="anonymous"></script> """
|
||||
else:
|
||||
return ''
|
||||
|
||||
@staticmethod
|
||||
def findThemeFile(theme):
|
||||
|
||||
@@ -480,6 +480,7 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader,
|
||||
restoreBTN.style.display = "none";
|
||||
}
|
||||
// for edit button
|
||||
|
||||
if (allFilesAndFolders.length === 1) {
|
||||
var editNode = document.getElementById("editFile");
|
||||
editNode.style.pointerEvents = "auto";
|
||||
@@ -813,6 +814,14 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader,
|
||||
|
||||
};
|
||||
|
||||
/// code mirror open
|
||||
|
||||
$scope.editWithCodeMirror = function(){
|
||||
var completePathForFile = $scope.currentPath + "/" + allFilesAndFolders[0];
|
||||
var finalURL = 'https://' + window.location.hostname + ':' + window.location.port + '/filemanager/editFile?domainName=' + domainName + '&fileName=' + completePathForFile;
|
||||
window.open(finalURL);
|
||||
};
|
||||
|
||||
|
||||
// uploads
|
||||
|
||||
|
||||
@@ -732,6 +732,7 @@
|
||||
<a style="border-bottom: 1px solid #007bff;" onclick="return false;" ng-click="showCompressionModal()" href="#"><li class="list-group-item"><i class="fa fa-compress" aria-hidden="true"></i> {% trans "Compress" %}</li></a>
|
||||
<a style="border-bottom: 1px solid #007bff;" id="extractOnRight" onclick="return false;" ng-click="showExtractionModal()" href="#"><li class="list-group-item"><i class="fa fa-expand" aria-hidden="true"></i> {% trans "Extract" %}</li></a>
|
||||
<a style="border-bottom: 1px solid #007bff;" id="editOnRight" onclick="return false;" ng-click="showHTMLEditorModal()" href="#"><li class="list-group-item"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> {% trans "Edit" %}</li></a>
|
||||
<a style="border-bottom: 1px solid #007bff;" id="editOnRightCodeMirror" onclick="return false;" ng-click="editWithCodeMirror()" href="#"><li class="list-group-item"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> {% trans "Edit with CodeMirror" %}</li></a>
|
||||
<a style="border-bottom: 1px solid #007bff;" id="restoreRight" onclick="return false;" ng-click="showRestoreModal()" href="#"><li class="list-group-item"><i class="fa fa-window-restore" aria-hidden="true"></i> {% trans "Restore" %}</li></a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -480,6 +480,7 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader,
|
||||
restoreBTN.style.display = "none";
|
||||
}
|
||||
// for edit button
|
||||
|
||||
if (allFilesAndFolders.length === 1) {
|
||||
var editNode = document.getElementById("editFile");
|
||||
editNode.style.pointerEvents = "auto";
|
||||
@@ -813,6 +814,14 @@ fileManager.controller('fileManagerCtrl', function ($scope, $http, FileUploader,
|
||||
|
||||
};
|
||||
|
||||
/// code mirror open
|
||||
|
||||
$scope.editWithCodeMirror = function(){
|
||||
var completePathForFile = $scope.currentPath + "/" + allFilesAndFolders[0];
|
||||
var finalURL = 'https://' + window.location.hostname + ':' + window.location.port + '/filemanager/editFile?domainName=' + domainName + '&fileName=' + completePathForFile;
|
||||
window.open(finalURL);
|
||||
};
|
||||
|
||||
|
||||
// uploads
|
||||
|
||||
|
||||
Reference in New Issue
Block a user