/* * Created by PyramIDE. * User: フランスのトトロ * Date: 06/02/2016 * Time: 15:40 * © Calexium */ read hayamiki_lib/types/hayamiki.anubis read tools/basis.anubis read tools/int.anubis read system/string.anubis read system/files.anubis read tools/streams.anubis read tools/ISO-8601.anubis read utils/utils.anubis define String generate_application_menu ( List(HK_App) apps, // List(HK_Table) tables, //list of the table model description String indent )= // hk_menu_list("111", help_text("222"), // [ // hk_menu_item("production_mass_storage", "view_table", "CURRENT", [("table_name", "production_mass_storage", ),("view_name", "current")]), //calculate then longest table name and add 4 for enclosed quote + coma + final space //hence we can make a beautiful formatting with max_space = longest_table_name_size(apps, 0) + 4, join(",\n", map((HK_App app) |-> since app is hk_app(app_name, icon, help, tables), indent+"hk_menu_list("+to_String(icon)+", "+ //determine if there is help text for app. If not we use the App name as menu entry with app_menu_name = if help is no_help_text then help_text(to_upper(if app_name ="" then "base" else app_name)) else help, to_Anubis_source(app_menu_name)+",\n"+indent+"[\n"+ join(",\n", map_append((HK_Table table) |-> since table is hk_table(table_name, short_name, model, display), since display is hk_display(list_views, _), map((HK_List_View view ) |-> with view_name = if view is list_view(v_name, _) then v_name else "default", indent+" "+"hk_menu_item("+fill("\""+table_name+"\",",max_space)+ "\"view_table\", "+ fill("help_text(\""+short_name+(if view_name="default" then "" else " "+view_name)+"\"),",max_space)+ "[(\"table_name\", "+fill("\""+table_name+"\",",max_space)+"),(\"view_name\", \""+view_name+"\")])", list_views), tables))+"\n"+indent+"])", apps)). public define Maybe(One) generate_menus ( List(HK_App) apps, //list of the table model description String dest_dir )= with file_name = dest_dir+"web_pages/generated/apps_menu.anubis", //create all necessary directories if doesn't exist. make_directories(file_name); //create script file name as new file. Previous file with same name will be erased if file(file_name, new) is { failure then println("Can't create menu "+file_name);failure, success(fd) then with stream = make_stream(fd), write_string(stream, "/* * Created by 早見木 (Hayamiki). * Date: "+_Int_to_ISO_8601_date(now)+" * Time: "+_Int_to_ISO_8601_time(now)+" */ transmit types/hk_menu_types.anubis public define HK_Menu_Item applications_menu = hk_menu_list(\"managers\", help_text_TAG(\"APPLICATIONS\"), [\n"+ generate_application_menu(apps, " ")+"\n ]).\n") } .