plugin.anubis
3.57 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
/*
* 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 calexium_lib/web/widgets/left_menu.anubis
transmit calexium_lib/web/types/making_a_web_site.anubis
read calexium_lib/web/types/controllers_web_site.anubis
read calexium_lib/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
//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
)
=
if (LoadAdm(WEB_Plugin))load_adm(file_name) is
{
file_not_found then print("File '"+file_name+"' not found.\n\n");failure,
read_error then print("Error reading file '"+file_name+"'.\n\n");failure,
timeout then print("Timeout when loading '"+file_name+"'.\n\n");failure,
file_damaged then print("File '"+file_name+"' is damaged.\n\n");failure,
bad_version(expected,found) then print("Secondary module '"+file_name+"' doesn't have the same\n"+
" version ("+found+") as primary module ("+expected+").\n\n");failure,
wrong_type(expected,found) then print("Secondary module '"+file_name+"' has type:\n"+
found+" while primary module expected:\n"+
expected+"\n\n");failure,
ok(ptah_plugin) then println("ptah plugin: APP ["+ptah_plugin.app_name+"] SPACE ["+ptah_plugin.space_name+"] loaded ");success(ptah_plugin)
}.
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"
)
=
with files = directory_list(directory, plugin_file_mask),
map_select((String file_name) |-> load_plugin(directory+file_name), files)
//merge_sort(all_list, migration_less)
.
public define Maybe(WEB_Plugin)
get_WEB_Plugin
(
List(WEB_Plugin) plugins,
String _app,
String _space
)=
if plugins is
{
[] then println("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)
}
.
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([]))
.