plugin.anubis
4.64 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
* Created by PyramIDE.
* User: フランスのトトロ aka (David RENÉ)
* Date: 30/07/2017
* Time: 01:33
* © David RENÉ
*/
read system/logger.anubis
//read app/app_constants.anubis
read xlib/web/widgets/left_menu.anubis
transmit xlib/web/types/making_a_web_site.anubis
transmit xlib/web/types/controllers_web_site.anubis
read xlib/web/widgets/menu.anubis
read hayamiki_lib/model/database.anubis
read hayamiki_lib/view/view_table_manager_types.anubis
public type WEB_Plugin:
web_plugin(
String app_name, //application name
String space_name, //space name
String version,
String date,
//version
(SQLite3DataBase db, HK_Database hk_db, VTM _vtm, (LogLevel, String) -> One logger) -> List(WEB_Controller) get_controller,
(SQLite3DataBase db, WEB_Session, String type) -> Maybe(HTML_Partial_Content) get_typed_content
// (One dummy) -> Plugin_Left_Menu get_plugin_left_menu
// (One dummy) -> Message get_API,
// (Message message) -> Message call_API
)
.
public define Maybe(WEB_Plugin)
load_plugin
(
String file_name,
(LogLevel, String) -> One logger
)=
if (LoadAdm(WEB_Plugin))load_adm(file_name) is
{
file_not_found then logger(logError, "File '"+file_name+"' not found.\n\n");failure,
read_error then logger(logError, "Error reading file '"+file_name+"'.\n\n");failure,
timeout then logger(logError, "Timeout when loading '"+file_name+"'.\n\n");failure,
file_damaged then logger(logError, "File '"+file_name+"' is damaged.\n\n");failure,
bad_version(expected,found) then logger(logError, "Secondary module '"+file_name+"' doesn't have the same\n"+
" version ("+found+") as primary module ("+expected+").\n\n");failure,
wrong_type(expected,found) then logger(logError, "Secondary module '"+file_name+"' has different type as expected by primary module\n");failure,
ok(web_plugin) then logger(logInfo, "web plugin loaded: APP ["+web_plugin.app_name+"] SPACE ["+web_plugin.space_name+"] version: "+web_plugin.version+" date: "+web_plugin.date+" loaded ");success(web_plugin)
}
.
public define Maybe(WEB_Plugin)
load_plugin
(
String file_name
)=
load_plugin(file_name, (LogLevel lvl, String string) |-> println(to_String(lvl)+" "+string))
.
public define List(WEB_Plugin)
all_plugins
(
String directory, //directory where search the plugin file below
String plugin_file_mask, //mask for loading plugin like "my_app_plugin_*.adm"
(LogLevel, String) -> One logger //
)=
with files = directory_list(directory, plugin_file_mask),
map_select(
(String file_name) |->
load_plugin(directory+file_name, logger)
,
files
)
.
public define List(WEB_Plugin)
all_plugins
(
String directory, //directory where search the plugin file below
String plugin_file_mask //mask for loading plugin like "my_app_plugin_*.adm"
)=
all_plugins(directory, plugin_file_mask, (LogLevel lvl, String string) |-> println(to_String(lvl)+" "+string))
.
public define Maybe(WEB_Plugin)
get_WEB_Plugin
(
List(WEB_Plugin) plugins,
String _app,
String _space,
(LogLevel, String) -> One logger
)=
if plugins is
{
[] then logger(logError, "get_WEB_Plugin for app ["+_app+"] space ["+_space+"] NOT FOUND");failure,
[h . t] then
if h.app_name = _app & h.space_name = _space then
//println("get_WEB_Plugin for app ["+_app+"] space ["+_space+"] OK");
success(h)
else
get_WEB_Plugin(t, _app, _space, logger)
}
.
public define Maybe(WEB_Plugin)
get_WEB_Plugin
(
List(WEB_Plugin) plugins,
String _app,
String _space
)=
get_WEB_Plugin(plugins, _app, _space, (LogLevel lvl, String string) |-> println(to_String(lvl)+" "+string))
.
public define World_Left_Menu
get_left_menu_from_plugins
(
List(WEB_Plugin) plugins,
World_Left_Menu current_world
)=
if plugins is
{
[] then current_world,
[h . t] then get_left_menu_from_plugins(t, add_to_World_Left_Menu(current_world, h.get_plugin_left_menu(unique)))
}
.
public define World_Left_Menu
get_left_menu_from_plugins
(
List(WEB_Plugin) plugins
)=
get_left_menu_from_plugins(plugins, world_menu([]))
.