Skip to content

Commit c56d600

Browse files
committed
Package ace editor with addon (no CDN/external JS)
1 parent cdbf6b1 commit c56d600

17 files changed

+792
-522
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ For now, the all modules are currently locked away behind only a usergroup == su
5757
- [Meta Construct](https://github.com/Metastruct "Meta Construct")
5858
- GLua mode for Ace Editor
5959
- [Phoenixf](https://github.com/phoen1xf/ "Phoenixf")
60-
- Hosting the Ace Editor glua mode & being an awesome friend <3
60+
- Being an awesome friend <3

js/mode-glua.js

Lines changed: 0 additions & 505 deletions
This file was deleted.

lua/autorun/blobsprofiler_autorun.lua

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,24 @@ end
2020

2121
MsgN("- blobsProfiler initializing files -")
2222

23-
local function incFile(path, CL, SV)
23+
local function incFile(fileData)
24+
local CL = fileData.CL or false
25+
local SV = fileData.SV or false
26+
local filePath = fileData.File or error("blobsProfiler: Failed to load file no .File provided!")
27+
2428
if SV && SERVER && !CL then
25-
print("[blobsProfiler] SV Load: " .. path)
26-
include("blobsprofiler/" .. path)
29+
print("[blobsProfiler] SV Load: " .. filePath)
30+
include("blobsprofiler/" .. filePath)
2731
else
2832
if SERVER then
29-
print("[blobsProfiler] " .. (SV && "SH" || "CL") .. " DL: " .. path)
30-
AddCSLuaFile("blobsprofiler/" .. path)
33+
print("[blobsProfiler] " .. (SV && "SH" || "CL") .. " DL: " .. filePath)
34+
AddCSLuaFile("blobsprofiler/" .. filePath)
3135
end
3236

3337
if (SV && CL) || (CL && CLIENT) then
34-
print("[blobsProfiler] " .. (SV && "SH" || "CL") .. " Load: " .. path)
35-
include("blobsprofiler/" .. path)
38+
print("[blobsProfiler] " .. (SV && "SH" || "CL") .. " Load: " .. filePath)
39+
if CLIENT and fileData.CL_NoInclude then print("[blobsProfiler] " .. (SV && "SH" || "CL") .. " CL_NoInclude: " .. filePath) return end
40+
include("blobsprofiler/" .. filePath)
3641
end
3742
end
3843
end
@@ -77,12 +82,12 @@ blobsProfiler.FileList = {
7782
{
7883
File = "server/sv_blobsprofiler.lua",
7984
SV = true,
80-
},
85+
}
8186
}
8287

8388
blobsProfiler.LoadFiles = function()
84-
for _, fileList in ipairs(blobsProfiler.FileList) do
85-
incFile(fileList.File, fileList.CL, fileList.SV)
89+
for _, fileData in ipairs(blobsProfiler.FileList) do
90+
incFile(fileData)
8691
end
8792
end
8893

@@ -101,4 +106,35 @@ blobsProfiler.LoadModules = function()
101106
end
102107
end
103108

104-
blobsProfiler.LoadModules()
109+
blobsProfiler.LoadModules()
110+
111+
local JSFiles = {
112+
{ FileName = "ace", Parts = 8 },
113+
{ FileName = "mode-sql" },
114+
{ FileName = "mode-glua", Parts = 4}
115+
}
116+
117+
blobsProfiler.JSFileData = blobsProfiler.JSFileData or {}
118+
119+
blobsProfiler.LoadJSFiles = function()
120+
for _, JSFile in ipairs(JSFiles) do
121+
local basePath = "blobsProfiler/client/js/" .. JSFile.FileName
122+
local partCount = JSFile.Parts or 1
123+
local parts = {}
124+
125+
for i = 1, partCount do
126+
local filePath = basePath .. (partCount > 1 and i or "") .. ".js.lua"
127+
if SERVER then
128+
AddCSLuaFile(filePath)
129+
else
130+
parts[i] = include(filePath)
131+
end
132+
end
133+
134+
if not SERVER then
135+
blobsProfiler.JSFileData[JSFile.FileName] = table.concat(parts)
136+
end
137+
end
138+
end
139+
140+
blobsProfiler.LoadJSFiles()

lua/blobsprofiler/client/cl_blobsprofiler.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,11 @@ blobsProfiler.generateAceEditorPanel = function(parentPanel, content, editorMode
113113
content = content or [[print("Hello world!")]]
114114
editorMode = editorMode or "Lua"
115115
local useMode = "ace/mode/glua"
116+
local useModeFile = "mode-glua"
116117

117118
if editorMode == "SQL" then
118119
useMode = "ace/mode/sql"
120+
useModeFile = "mode-sql"
119121
end
120122

121123
dhtmlPanel:SetHTML([[
@@ -133,15 +135,12 @@ blobsProfiler.generateAceEditorPanel = function(parentPanel, content, editorMode
133135
</head>
134136
<body>
135137
<div id="editor">]].. content ..[[</div>
136-
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.13/ace.js" type="text/javascript" charset="utf-8"></script>
137-
<script src="https://cdn.hbn.gg/thirdparty/mode-glua.js" type="text/javascript"></script>
138+
<script>]].. blobsProfiler.JSFileData["ace"] ..[[</script>
139+
<script>]].. blobsProfiler.JSFileData[useModeFile] ..[[</script>
138140
<script>
139141
var editor = ace.edit("editor");
140142
editor.session.setMode("]].. useMode ..[[");
141143
editor.setOptions({
142-
enableBasicAutocompletion: true,
143-
enableSnippets: true,
144-
enableLiveAutocompletion: true,
145144
showLineNumbers: true,
146145
tabSize: 2
147146
});
@@ -1178,6 +1177,7 @@ concommand.Add("blobsprofiler", function(ply, cmd, args, argStr)
11781177
subPropertySheetText = " - " .. subActiveTab:GetText()
11791178
end
11801179
blobsProfiler.Menu.MenuFrame:SetTitle("blobsProfiler - " .. blobsProfiler.Menu.selectedRealm .. subPropertySheetText)
1180+
if not subActiveTab then return end
11811181

11821182
if blobsProfiler.Modules[subActiveTab:GetText()] and firstSubModule[subActiveTab:GetText()] then
11831183
if pnlNew:GetText() == "Server" and firstSubModule[subActiveTab:GetText()].data.UpdateRealmData then

lua/blobsprofiler/client/js/ace1.js.lua

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

lua/blobsprofiler/client/js/ace2.js.lua

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

lua/blobsprofiler/client/js/ace3.js.lua

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

lua/blobsprofiler/client/js/ace4.js.lua

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

lua/blobsprofiler/client/js/ace5.js.lua

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

lua/blobsprofiler/client/js/ace6.js.lua

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)