-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.lua
69 lines (49 loc) · 1.55 KB
/
Main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
LogInfo("Loading YaleAeonSpace plugin")
luanet.load_assembly("System")
luanet.load_assembly("System.Data")
luanet.load_assembly("System.Net")
require("Atlas-Addons-Lua-ParseJson.JsonParser")
Ctx = {
Encoding = luanet.import_type("System.Text.Encoding"),
DataTable = luanet.import_type("System.Data.DataTable"),
WebClient = luanet.import_type("System.Net.WebClient"),
NameValueCollection = luanet.import_type("System.Collections.Specialized.NameValueCollection"),
InterfaceManager = GetInterfaceManager(),
BaseUrl = GetSetting("ArchivesSpaceAPIURL"),
Username = GetSetting("ArchivesSpaceUser"),
Password = GetSetting("ArchivesSpacePassword")
}
-- Base URL requires a trailing slash
Ctx.BaseUrl = string.gsub(Ctx.BaseUrl .. "/", "/+$", "/")
function fileExists(path)
local fh = io.open(path, "r")
if fh == nil then
return false
else
io.close(fh)
return true
end
end
function findInPath(name)
local haystack = package.path .. ";"
local start_idx = 0
while true do
end_idx = string.find(haystack, ";", start_idx)
if end_idx == nil then
break
end
local pattern = string.sub(haystack, start_idx, end_idx - 1)
if (fileExists(string.gsub(pattern, "?", name))) then
result, _ = string.gsub(pattern, "?", name)
return result
end
start_idx = end_idx + 1
end
return nil
end
function Init()
local mainProgram = findInPath("YaleAeonAspace")
dofile(mainProgram)
Ctx.PluginBaseDir = mainProgram:match("(.*\\)")
ConfigureForm()
end