/* * 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/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, (WEB_Session, String type) -> Maybe(HTML_Partial_Content) get_typed_content // (One dummy) -> Plugin_Left_Menu get_plugin_left_menu // (One dummy) -> // (One dummy) -> Message get_API, // (Message message) -> Message call_API // (One dummy) -> Menu get_menu, ) . 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(modules_directory, plugin_file_mask), map_select((String file_name) |-> load_plugin(modules_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([])) .