diff --git a/CXM_message_constants.anubis b/CXM_message_constants.anubis deleted file mode 100644 index e60aed4..0000000 --- a/CXM_message_constants.anubis +++ /dev/null @@ -1,228 +0,0 @@ -/* - * - * User: David RENÉ - * Date: 07/04/2007 - * Time: 16:06 - * © David RENÉ - * - */ - -public define Word32 _NO_NAME_MSG = 0x00000000. - -// **************** MAILBOX PROTOCOL *************** - -public define Word32 _C_SCAN_FOR_BOXES = 0x33770001. // Ask Boxes to publish their informations -public define Word32 _C_PUBLISH_BOX_STATUS = 0x33770002. // Used by Boxes to publish their informations -public define Word32 _C_SHUTDOWN_BOX = 0x33770003. // Used to ask a box to shutdown -public define Word32 _CXM_SET_BOX_NETWORK_PARAMS = 0x33770004. // Define network configuration of boxes -public define Word32 _CXM_RESET_ADMIN_PWD = 0x33770005. // Ask the MailFountain to reset the admin pwd. -public define Word32 _CXM_FULL_RESET = 0x33770006. // Ask the MailFountain to proceed to a full reset of its data. After that, the MailFountain is totally empty (mail, config, domain, logs, etc...) -public define Word32 _CXM_FORCE_PUBLISH_MF_CONFIG = 0x33770007. // Ask the MailFountain to proceed a Config publishing to DomainManager - - // **************** PACKAGE BUILDER *************** - -public define Word32 _CXM_PKG_MSG_BASIS = 0x33770400. // -public define Word32 _CXM_PKG_CONTAINER = 0x33770401. -public define Word32 _CXM_PKG_HEADER_PART = 0x33770402. // Header Message for Script -public define Word32 _CXM_PKG_SCRIPT_PART = 0x33770403. // Main Message for Script -public define Word32 _CXM_PKG_S_ADD_FILE = 0x33770404. // script action to add file in the destination -public define Word32 _CXM_PKG_S_RUN = 0x33770405. // script action to run a command -public define Word32 _CXM_PKG_INDEX_PART = 0x33770440. // ID of package Index part -public define Word32 _CXM_PKG_IDX_ENTRY = 0x33770441. // Index entry information - - // **************** UPDATE SERVICE *************** - -public define Word32 _CXM_UPDATE_SERVICE_MSG_BASIS = 0x33770800. // -public define Word32 _CXM_UPD_SERVICE_ID = 0x33770801. -public define Word32 _CXM_UPD_HAS_UPDATE = 0x33770802. // -public define Word32 _CXM_UPD_LIST_CLASS_FILES = 0x33770803. // List the files contained in the class path -public define Word32 _CXM_UPD_GET_CLASS_FILE = 0x33770804. // get the file contained in the class path. Return info for download - - // **************** SERVICE NEGOCIATION *************** - -public define Word32 _CXM_SERVICE_NEGOCIATION_BASIS = 0x33770C00. // -public define Word32 _CXM_REQUEST_FOR_SERVICE = 0x33770C01. // -public define Word32 _CXM_LOGIN = 0x33770C02. // - - // **************** GENERIC PROTOCOL *************** - -public define Word32 _CXM_GENERIC_PROTOCOL_BASIS = 0x33771000. // -public define Word32 _CXM_ACK = 0x33771001. // -public define Word32 _CXM_ACK_RESULT_MSG = 0x33771002. // -public define Word32 _CXM_GET_FILE_REF = 0x33771003. //get local or remote file without FTP service - - // **************** FTP SERVICE *************** - -public define Word32 _CXM_FTP_SERVICE_MSG_BASIS = 0x33771400. // -public define Word32 _CXM_FTP_SERVICE_ID = 0x33771401. -public define Word32 _CXM_FTP_GET_FILE = 0x33771402. -public define Word32 _CXM_FTP_START_TRANSFERT = 0x33771403. -public define Word32 _CXM_FTP_DATA = 0x33771404. - - // ************** LOGGER SERVICE ************** - -public define Word32 _CXM_LOGGER_SERVICE_MSG_BASIS = 0x33771800. // -public define Word32 _CXM_LOGGER_SERVICE_ID = 0x33771801. -public define Word32 _CXM_LOGGER_LOG = 0x33771802. -public define Word32 _CXM_LOGGER_REGISTER_UID = 0x33771803. -public define Word32 _CXM_LOGGER_REGISTER_LOG = 0x33771804. - - // ************** DOMAIN SERVICE ************** - -// MF <-> DomainManager -public define Word32 _CXM_DOMAIN_SERVICE_MSG_BASIS = 0x33771C00. // -public define Word32 _CXM_DOMAIN_SERVICE_ID = 0x33771C01. -public define Word32 _CXM_DOMAIN_PUBLISH_MF_CONFIG = 0x33771C02. -public define Word32 _CXM_DOMAIN_GET_NAME = 0x33771C03. -public define Word32 _CXM_DOMAIN_GET_MY_IP = 0x33771C04. -public define Word32 _CXM_DOMAIN_PUBLISH_MY_IP = 0x33771C05. -public define Word32 _CXM_DOMAIN_PUBLISH_DYN_TEST = 0x33771C06. -public define Word32 _CXM_DOMAIN_GET_STATUS = 0x33771C07. -public define Word32 _CXM_DOMAIN_GET_DOMAIN_INFO = 0x33771C08. -public define Word32 _CXM_DOMAIN_CRITICAL_ALERT = 0x33771C09. -public define Word32 _CXM_DOMAIN_COMMAND_RESULT = 0x33771C0A. - - -// DomainManager <-> Gandi -public define Word32 _CXM_GANDI_SERVICE_ID = 0x33771D00. -public define Word32 _CXM_GANDI_CHECK_AVAILABILITY = 0x33771D01. // 'NAME' (String): Base names (without extension) of the wanted domains - // --> CXM_ACK with 'DOMAINS' (String): Array of avaiblable domains -public define Word32 _CXM_GANDI_CREATE_CONTACT = 0x33771D02. // 'CLASS' (String): - // 'FIRSTNAME', 'LASTNAME', 'ADDRESS', 'ZIPCODE', 'CITY', 'COUNTRY', 'PHONE', 'EMAIL' (String) - // --> CXM_ACK with 'CONTACT_HANDLE' (String): Created handle for this contact -public define Word32 _CXM_GANDI_CREATE_DOMAIN = 0x33771D03. // 'DOMAIN' (String): Domain full name - // 'OWNER' (String): Owner handle - // --> CXM_ACK with 'DOMAIN_HANDLE' (String): Created handle for this domain - // ************** MF INSTALLER SERVICE ************** - -public define Word32 _CXM_INSTALLER_SERVICE_MSG_BASIS= 0x33772000. -public define Word32 _CXM_INSTALLER_SERVICE_ID = 0x33772001. -public define Word32 _CXM_INSTALLER_REGISTER_APP_ID = 0x33772002. -public define Word32 _CXM_INSTALLER_GET_NEW_SERIALS = 0x33772003. -public define Word32 _CXM_INSTALLER_CONFIRM_SERIALS_PUBLICATION = 0x33772004. -public define Word32 _CXM_INSTALLER_GET_MODELS = 0x33772005. // returns the MF models list - -// ************************************************* -// ************* MF API ************* - -// ************* ADMIN SERVICE ************* - -public define Word32 _CXM_ADMIN_SERVICE_MSG_BASIS = 0x33772100. -public define Word32 _CXM_ADMIN_SERVICE_ID = 0x33772100. -public define Word32 _CXM_ADMIN_CREATE_ACCOUNT = 0x33772101. -public define Word32 _CXM_ADMIN_DELETE_ACCOUNT = 0x33772102. - - - - -// ************* MAILINGS SERVICE ************* - -public define Word32 _CXM_MAILING_SERVICE_MSG_BASIS = 0x33772200. -public define Word32 _CXM_MAILING_SERVICE_ID = 0x33772200. // same as MSG_BASIS - -public define Word32 _CXM_MAILING_CREATE_CONTACT = 0x33772201. -public define Word32 _CXM_MAILING_UPDATE_CONTACT = 0x33772202. -public define Word32 _CXM_MAILING_DELETE_CONTACT = 0x33772203. -public define Word32 _CXM_MAILING_CHECK_CONTACT = 0x33772204. - -public define Word32 _CXM_MAILING_CREATE_MAILING = 0x33772211. -public define Word32 _CXM_MAILING_UPDATE_MAILING = 0x33772212. -public define Word32 _CXM_MAILING_DELETE_MAILING = 0x33772213. -public define Word32 _CXM_MAILING_GET_MAILING = 0x33772214. - -public define Word32 _CXM_MAILING_ADD_CONTACT_TO_MAILING = 0x33772221. -public define Word32 _CXM_MAILING_REMOVE_CONTACT_FROM_MAILING = 0x33772222. - - -// ************* DIRECTORY SERVICE ************* - -public define Word32 _CXM_DIRECTORY_SERVICE_MSG_BASIS = 0x33772300. - -// ************* BACKUP SERVICE ************* - -public define Word32 _CXM_BACKUP_SERVICE_MSG_BASIS = 0x33772400. -public define Word32 _CXM_BACKUP_SERVICE_ID = 0x33772401. -public define Word32 _CXM_BACKUP_GET_STATUS = 0x33772402. /// Get backup status for a given MF (can subscribe, subscribed, subscription end date...) -public define Word32 _CXM_BACKUP_STARTING_BACKUP = 0x33772403. /// Notify BackupService that backup process is starting -public define Word32 _CXM_BACKUP_FINISHING_BACKUP = 0x33772404. /// Notify BackupService that backup process is finishing -public define Word32 _CXM_BACKUP_STARTING_RESTORE = 0x33772405. /// Notify BackupService that restore process is starting -public define Word32 _CXM_BACKUP_FINISHING_RESTORE = 0x33772406. /// Notify BackupService that restore process is finishing - -// ************* STATISTICS SERVICE ************* - -public define Word32 _CXM_STATS_SERVICE_MSG_BASIS = 0x33772500. - -// ************* SUPERVISER SERVICE ************* - -public define Word32 _CXM_SUPERVISER_SERVICE_MSG_BASIS = 0x33772600. -public define Word32 _CXM_SUPERVISER_SERVICE_ID = 0x33772600. -public define Word32 _CXM_SUPERVISER_GET_STATUS = 0x33772601. - -// ************* OTHER MESSAGES ************* - -public define Word32 _CXM_MF_MODEL = 1296912196. // 'MMOD' -public define Word32 _CXM_MF_LICENSE = 1296845123. // 'MLIC' - -// ************* TEGAMIGAWA SERVICE ************* - -public define Word32 _CXM_TEGAMIGAWA_SERVICE_MSG_BASIS = 0x33772700. -public define Word32 _CXM_TEGAMIGAWA_SERVICE_ID = 0x33772700. -public define Word32 _CXM_TEGAMIGAWA_REGISTER_CLIENT = 0x33772701. - -// *************** KAIWA SERVICE *************** - -public define Word32 _CXM_KAIWA_SERVICE_MSG_BASIS = 0x33772800. -public define Word32 _CXM_KAIWA_SERVICE_ID = 0x33772800. -public define Word32 _CXM_KAIWA_REGISTER_CLIENT = 0x33772801. -public define Word32 _CXM_KAIWA_FRIEND_REQUEST = 0x33772802. -public define Word32 _CXM_KAIWA_ADD_FRIEND = 0x33772803. -public define Word32 _CXM_KAIWA_REMOVE_FRIEND = 0x33772804. -public define Word32 _CXM_KAIWA_BLOCK_FRIEND = 0x33772805. -public define Word32 _CXM_KAIWA_ONLINE_STATUS = 0x33772806. -public define Word32 _CXM_KAIWA_SEND_MESSAGE = 0x33772807. -public define Word32 _CXM_KAIWA_RECEIVE_MESSAGE = 0x33772808. - -// ************* MAIL SERVICE ************* - -public define Word32 _CXM_MF_MAIL_SERVICE_MSG_BASIS = 0x33772900. -public define Word32 _CXM_MF_MAIL_SERVICE_ID = 0x33772900. -public define Word32 _CXM_MF_MAIL_SEND_MAIL = 0x33772901. - -// ************************************************* -// ************* BASILIK SERVICES ************* -public define Word32 _CXM_BSLK_MSG_BASIS = 0x33780000. -public define Word32 _CXM_BSLK_SERVICE_ID = 0x33780000. -public define Word32 _CXM_BSLKLP_SERVICE_ID = 0x33781000. -public define Word32 _CXM_BSLKLP_LOG = 0x33781001. - - - -// ************************************************* -// ********* HAYAMIKI RESERVED SPACE ********** - -public define Word32 _CXM_HK_MSG_BASIS = 0x33790000. -public define Word32 _HK_DATABASE = 0x33790400. -public define Word32 _HK_APP = 0x33790401. -public define Word32 _HK_TABLE = 0x33790402. -public define Word32 _HK_MODEL = 0x33790403. -public define Word32 _HK_COLUMN = 0x33790404. -public define Word32 _HK_COLUMN_ATTRIBUTES = 0X33790405. -public define Word32 _HK_FIELD = 0x33790406. - -public define Word32 _HK_ICON = 0x33790410. -public define Word32 _HK_HELP_TEXT = 0x33790411. -public define Word32 _HK_MODEL_DISPLAY = 0x33790412. -public define Word32 _HK_LIST_VIEW = 0x33790413. -public define Word32 _HK_EDIT_VIEW = 0x33790414. -public define Word32 _HK_APP_NAME = 0x33790415. - -public define Word32 _CXM_HK_MSG_END = 0x3379FFFF. - -// ************************************************* -// ********* ANUBIX RESERVED SPACE ********** - -public define Word32 _RMT_ANUBIX_MSG_BASIS = 0x33800000. -public define Word32 _RMT_ANUBIX_CORE_SERVICE_ID = 0x33800000. -public define Word32 _RMT_ANUBIX_CORE_AUTH = 0x33800001. - -public define Word32 _RMT_ANUBIX_MSG_END = 0x3380FFFF. diff --git a/asterisk/ami.anubis b/asterisk/ami.anubis index 6fab15e..a86e268 100644 --- a/asterisk/ami.anubis +++ b/asterisk/ami.anubis @@ -13,7 +13,7 @@ read network/dns.anubis transmit xlib/asterisk/ami_types.anubis transmit xlib/asterisk/ami_commands.anubis -transmit xlib/web/CXM_http_get_common.anubis +transmit xlib/web/http_get_common.anubis define Maybe(List(String)) receive diff --git a/database/db_types.anubis b/database/db_types.anubis index 03199fb..24d5c50 100644 --- a/database/db_types.anubis +++ b/database/db_types.anubis @@ -14,7 +14,7 @@ transmit xlib/database/types/db_date.anubis transmit xlib/database/types/db_time.anubis transmit xlib/database/types/db_datetime.anubis transmit xlib/database/types/db_integer.anubis -transmit xlib/web/CXM_json.anubis +transmit xlib/web/json.anubis /* DB_id will is deprecated. Please use next version below all upper case */ //public type DB_id: diff --git a/message_constants.anubis b/message_constants.anubis new file mode 100644 index 0000000..e60aed4 --- /dev/null +++ b/message_constants.anubis @@ -0,0 +1,228 @@ +/* + * + * User: David RENÉ + * Date: 07/04/2007 + * Time: 16:06 + * © David RENÉ + * + */ + +public define Word32 _NO_NAME_MSG = 0x00000000. + +// **************** MAILBOX PROTOCOL *************** + +public define Word32 _C_SCAN_FOR_BOXES = 0x33770001. // Ask Boxes to publish their informations +public define Word32 _C_PUBLISH_BOX_STATUS = 0x33770002. // Used by Boxes to publish their informations +public define Word32 _C_SHUTDOWN_BOX = 0x33770003. // Used to ask a box to shutdown +public define Word32 _CXM_SET_BOX_NETWORK_PARAMS = 0x33770004. // Define network configuration of boxes +public define Word32 _CXM_RESET_ADMIN_PWD = 0x33770005. // Ask the MailFountain to reset the admin pwd. +public define Word32 _CXM_FULL_RESET = 0x33770006. // Ask the MailFountain to proceed to a full reset of its data. After that, the MailFountain is totally empty (mail, config, domain, logs, etc...) +public define Word32 _CXM_FORCE_PUBLISH_MF_CONFIG = 0x33770007. // Ask the MailFountain to proceed a Config publishing to DomainManager + + // **************** PACKAGE BUILDER *************** + +public define Word32 _CXM_PKG_MSG_BASIS = 0x33770400. // +public define Word32 _CXM_PKG_CONTAINER = 0x33770401. +public define Word32 _CXM_PKG_HEADER_PART = 0x33770402. // Header Message for Script +public define Word32 _CXM_PKG_SCRIPT_PART = 0x33770403. // Main Message for Script +public define Word32 _CXM_PKG_S_ADD_FILE = 0x33770404. // script action to add file in the destination +public define Word32 _CXM_PKG_S_RUN = 0x33770405. // script action to run a command +public define Word32 _CXM_PKG_INDEX_PART = 0x33770440. // ID of package Index part +public define Word32 _CXM_PKG_IDX_ENTRY = 0x33770441. // Index entry information + + // **************** UPDATE SERVICE *************** + +public define Word32 _CXM_UPDATE_SERVICE_MSG_BASIS = 0x33770800. // +public define Word32 _CXM_UPD_SERVICE_ID = 0x33770801. +public define Word32 _CXM_UPD_HAS_UPDATE = 0x33770802. // +public define Word32 _CXM_UPD_LIST_CLASS_FILES = 0x33770803. // List the files contained in the class path +public define Word32 _CXM_UPD_GET_CLASS_FILE = 0x33770804. // get the file contained in the class path. Return info for download + + // **************** SERVICE NEGOCIATION *************** + +public define Word32 _CXM_SERVICE_NEGOCIATION_BASIS = 0x33770C00. // +public define Word32 _CXM_REQUEST_FOR_SERVICE = 0x33770C01. // +public define Word32 _CXM_LOGIN = 0x33770C02. // + + // **************** GENERIC PROTOCOL *************** + +public define Word32 _CXM_GENERIC_PROTOCOL_BASIS = 0x33771000. // +public define Word32 _CXM_ACK = 0x33771001. // +public define Word32 _CXM_ACK_RESULT_MSG = 0x33771002. // +public define Word32 _CXM_GET_FILE_REF = 0x33771003. //get local or remote file without FTP service + + // **************** FTP SERVICE *************** + +public define Word32 _CXM_FTP_SERVICE_MSG_BASIS = 0x33771400. // +public define Word32 _CXM_FTP_SERVICE_ID = 0x33771401. +public define Word32 _CXM_FTP_GET_FILE = 0x33771402. +public define Word32 _CXM_FTP_START_TRANSFERT = 0x33771403. +public define Word32 _CXM_FTP_DATA = 0x33771404. + + // ************** LOGGER SERVICE ************** + +public define Word32 _CXM_LOGGER_SERVICE_MSG_BASIS = 0x33771800. // +public define Word32 _CXM_LOGGER_SERVICE_ID = 0x33771801. +public define Word32 _CXM_LOGGER_LOG = 0x33771802. +public define Word32 _CXM_LOGGER_REGISTER_UID = 0x33771803. +public define Word32 _CXM_LOGGER_REGISTER_LOG = 0x33771804. + + // ************** DOMAIN SERVICE ************** + +// MF <-> DomainManager +public define Word32 _CXM_DOMAIN_SERVICE_MSG_BASIS = 0x33771C00. // +public define Word32 _CXM_DOMAIN_SERVICE_ID = 0x33771C01. +public define Word32 _CXM_DOMAIN_PUBLISH_MF_CONFIG = 0x33771C02. +public define Word32 _CXM_DOMAIN_GET_NAME = 0x33771C03. +public define Word32 _CXM_DOMAIN_GET_MY_IP = 0x33771C04. +public define Word32 _CXM_DOMAIN_PUBLISH_MY_IP = 0x33771C05. +public define Word32 _CXM_DOMAIN_PUBLISH_DYN_TEST = 0x33771C06. +public define Word32 _CXM_DOMAIN_GET_STATUS = 0x33771C07. +public define Word32 _CXM_DOMAIN_GET_DOMAIN_INFO = 0x33771C08. +public define Word32 _CXM_DOMAIN_CRITICAL_ALERT = 0x33771C09. +public define Word32 _CXM_DOMAIN_COMMAND_RESULT = 0x33771C0A. + + +// DomainManager <-> Gandi +public define Word32 _CXM_GANDI_SERVICE_ID = 0x33771D00. +public define Word32 _CXM_GANDI_CHECK_AVAILABILITY = 0x33771D01. // 'NAME' (String): Base names (without extension) of the wanted domains + // --> CXM_ACK with 'DOMAINS' (String): Array of avaiblable domains +public define Word32 _CXM_GANDI_CREATE_CONTACT = 0x33771D02. // 'CLASS' (String): + // 'FIRSTNAME', 'LASTNAME', 'ADDRESS', 'ZIPCODE', 'CITY', 'COUNTRY', 'PHONE', 'EMAIL' (String) + // --> CXM_ACK with 'CONTACT_HANDLE' (String): Created handle for this contact +public define Word32 _CXM_GANDI_CREATE_DOMAIN = 0x33771D03. // 'DOMAIN' (String): Domain full name + // 'OWNER' (String): Owner handle + // --> CXM_ACK with 'DOMAIN_HANDLE' (String): Created handle for this domain + // ************** MF INSTALLER SERVICE ************** + +public define Word32 _CXM_INSTALLER_SERVICE_MSG_BASIS= 0x33772000. +public define Word32 _CXM_INSTALLER_SERVICE_ID = 0x33772001. +public define Word32 _CXM_INSTALLER_REGISTER_APP_ID = 0x33772002. +public define Word32 _CXM_INSTALLER_GET_NEW_SERIALS = 0x33772003. +public define Word32 _CXM_INSTALLER_CONFIRM_SERIALS_PUBLICATION = 0x33772004. +public define Word32 _CXM_INSTALLER_GET_MODELS = 0x33772005. // returns the MF models list + +// ************************************************* +// ************* MF API ************* + +// ************* ADMIN SERVICE ************* + +public define Word32 _CXM_ADMIN_SERVICE_MSG_BASIS = 0x33772100. +public define Word32 _CXM_ADMIN_SERVICE_ID = 0x33772100. +public define Word32 _CXM_ADMIN_CREATE_ACCOUNT = 0x33772101. +public define Word32 _CXM_ADMIN_DELETE_ACCOUNT = 0x33772102. + + + + +// ************* MAILINGS SERVICE ************* + +public define Word32 _CXM_MAILING_SERVICE_MSG_BASIS = 0x33772200. +public define Word32 _CXM_MAILING_SERVICE_ID = 0x33772200. // same as MSG_BASIS + +public define Word32 _CXM_MAILING_CREATE_CONTACT = 0x33772201. +public define Word32 _CXM_MAILING_UPDATE_CONTACT = 0x33772202. +public define Word32 _CXM_MAILING_DELETE_CONTACT = 0x33772203. +public define Word32 _CXM_MAILING_CHECK_CONTACT = 0x33772204. + +public define Word32 _CXM_MAILING_CREATE_MAILING = 0x33772211. +public define Word32 _CXM_MAILING_UPDATE_MAILING = 0x33772212. +public define Word32 _CXM_MAILING_DELETE_MAILING = 0x33772213. +public define Word32 _CXM_MAILING_GET_MAILING = 0x33772214. + +public define Word32 _CXM_MAILING_ADD_CONTACT_TO_MAILING = 0x33772221. +public define Word32 _CXM_MAILING_REMOVE_CONTACT_FROM_MAILING = 0x33772222. + + +// ************* DIRECTORY SERVICE ************* + +public define Word32 _CXM_DIRECTORY_SERVICE_MSG_BASIS = 0x33772300. + +// ************* BACKUP SERVICE ************* + +public define Word32 _CXM_BACKUP_SERVICE_MSG_BASIS = 0x33772400. +public define Word32 _CXM_BACKUP_SERVICE_ID = 0x33772401. +public define Word32 _CXM_BACKUP_GET_STATUS = 0x33772402. /// Get backup status for a given MF (can subscribe, subscribed, subscription end date...) +public define Word32 _CXM_BACKUP_STARTING_BACKUP = 0x33772403. /// Notify BackupService that backup process is starting +public define Word32 _CXM_BACKUP_FINISHING_BACKUP = 0x33772404. /// Notify BackupService that backup process is finishing +public define Word32 _CXM_BACKUP_STARTING_RESTORE = 0x33772405. /// Notify BackupService that restore process is starting +public define Word32 _CXM_BACKUP_FINISHING_RESTORE = 0x33772406. /// Notify BackupService that restore process is finishing + +// ************* STATISTICS SERVICE ************* + +public define Word32 _CXM_STATS_SERVICE_MSG_BASIS = 0x33772500. + +// ************* SUPERVISER SERVICE ************* + +public define Word32 _CXM_SUPERVISER_SERVICE_MSG_BASIS = 0x33772600. +public define Word32 _CXM_SUPERVISER_SERVICE_ID = 0x33772600. +public define Word32 _CXM_SUPERVISER_GET_STATUS = 0x33772601. + +// ************* OTHER MESSAGES ************* + +public define Word32 _CXM_MF_MODEL = 1296912196. // 'MMOD' +public define Word32 _CXM_MF_LICENSE = 1296845123. // 'MLIC' + +// ************* TEGAMIGAWA SERVICE ************* + +public define Word32 _CXM_TEGAMIGAWA_SERVICE_MSG_BASIS = 0x33772700. +public define Word32 _CXM_TEGAMIGAWA_SERVICE_ID = 0x33772700. +public define Word32 _CXM_TEGAMIGAWA_REGISTER_CLIENT = 0x33772701. + +// *************** KAIWA SERVICE *************** + +public define Word32 _CXM_KAIWA_SERVICE_MSG_BASIS = 0x33772800. +public define Word32 _CXM_KAIWA_SERVICE_ID = 0x33772800. +public define Word32 _CXM_KAIWA_REGISTER_CLIENT = 0x33772801. +public define Word32 _CXM_KAIWA_FRIEND_REQUEST = 0x33772802. +public define Word32 _CXM_KAIWA_ADD_FRIEND = 0x33772803. +public define Word32 _CXM_KAIWA_REMOVE_FRIEND = 0x33772804. +public define Word32 _CXM_KAIWA_BLOCK_FRIEND = 0x33772805. +public define Word32 _CXM_KAIWA_ONLINE_STATUS = 0x33772806. +public define Word32 _CXM_KAIWA_SEND_MESSAGE = 0x33772807. +public define Word32 _CXM_KAIWA_RECEIVE_MESSAGE = 0x33772808. + +// ************* MAIL SERVICE ************* + +public define Word32 _CXM_MF_MAIL_SERVICE_MSG_BASIS = 0x33772900. +public define Word32 _CXM_MF_MAIL_SERVICE_ID = 0x33772900. +public define Word32 _CXM_MF_MAIL_SEND_MAIL = 0x33772901. + +// ************************************************* +// ************* BASILIK SERVICES ************* +public define Word32 _CXM_BSLK_MSG_BASIS = 0x33780000. +public define Word32 _CXM_BSLK_SERVICE_ID = 0x33780000. +public define Word32 _CXM_BSLKLP_SERVICE_ID = 0x33781000. +public define Word32 _CXM_BSLKLP_LOG = 0x33781001. + + + +// ************************************************* +// ********* HAYAMIKI RESERVED SPACE ********** + +public define Word32 _CXM_HK_MSG_BASIS = 0x33790000. +public define Word32 _HK_DATABASE = 0x33790400. +public define Word32 _HK_APP = 0x33790401. +public define Word32 _HK_TABLE = 0x33790402. +public define Word32 _HK_MODEL = 0x33790403. +public define Word32 _HK_COLUMN = 0x33790404. +public define Word32 _HK_COLUMN_ATTRIBUTES = 0X33790405. +public define Word32 _HK_FIELD = 0x33790406. + +public define Word32 _HK_ICON = 0x33790410. +public define Word32 _HK_HELP_TEXT = 0x33790411. +public define Word32 _HK_MODEL_DISPLAY = 0x33790412. +public define Word32 _HK_LIST_VIEW = 0x33790413. +public define Word32 _HK_EDIT_VIEW = 0x33790414. +public define Word32 _HK_APP_NAME = 0x33790415. + +public define Word32 _CXM_HK_MSG_END = 0x3379FFFF. + +// ************************************************* +// ********* ANUBIX RESERVED SPACE ********** + +public define Word32 _RMT_ANUBIX_MSG_BASIS = 0x33800000. +public define Word32 _RMT_ANUBIX_CORE_SERVICE_ID = 0x33800000. +public define Word32 _RMT_ANUBIX_CORE_AUTH = 0x33800001. + +public define Word32 _RMT_ANUBIX_MSG_END = 0x3380FFFF. diff --git a/net_services/CXM_generic_client.anubis b/net_services/CXM_generic_client.anubis index f1a8546..4d52d37 100644 --- a/net_services/CXM_generic_client.anubis +++ b/net_services/CXM_generic_client.anubis @@ -13,9 +13,9 @@ read network/dns.anubis //transmit xlib/net_services_protocols/logger_service.anubis -transmit xlib/CXM_message_constants.anubis -transmit xlib/net_services/CXM_net_services.anubis -transmit xlib/net_services/CXM_generic_protocol.anubis +transmit xlib/message_constants.anubis +transmit xlib/net_services/net_services.anubis +transmit xlib/net_services/generic_protocol.anubis // --Generic types--------------------------------------------------------------------- public type NetServiceAnswer: diff --git a/net_services_protocols/logger_client.anubis b/net_services_protocols/logger_client.anubis index 3f173f5..921c88d 100644 --- a/net_services_protocols/logger_client.anubis +++ b/net_services_protocols/logger_client.anubis @@ -9,7 +9,7 @@ transmit system/logger.anubis read system/message_transceiver.anubis read system/parameter/inifile.anubis -read xlib/CXM_message_constants.anubis +read xlib/message_constants.anubis define One local_net_logger diff --git a/net_services_protocols/logger_service_deprecated.anubis b/net_services_protocols/logger_service_deprecated.anubis index f45a030..0a2136d 100644 --- a/net_services_protocols/logger_service_deprecated.anubis +++ b/net_services_protocols/logger_service_deprecated.anubis @@ -18,9 +18,9 @@ read system/message_transceiver.anubis read system/files.anubis -read xlib/CXM_message_constants.anubis -read xlib/net_services/CXM_net_services.anubis -read xlib/net_services/CXM_generic_protocol.anubis +read xlib/message_constants.anubis +read xlib/net_services/net_services.anubis +read xlib/net_services/generic_protocol.anubis // Special non-existing file. This is a work arround for a impossibility to define global configuration in anubis. // So this file allows you to specify on which UDP port the logger server is listening. diff --git a/unit_test/test.anubis b/unit_test/test.anubis index 047f60d..5a91e9f 100644 --- a/unit_test/test.anubis +++ b/unit_test/test.anubis @@ -7,9 +7,9 @@ */ -read xlib/web/CXM_multihost_http_server.anubis -read xlib/web/CXM_web_arg_utils.anubis -read xlib/web/CXM_web_dump.anubis +read xlib/web/multihost_http_server.anubis +read xlib/web/web_arg_utils.anubis +read xlib/web/web_dump.anubis read tools/string.anubis global define One diff --git a/web/CXM_common.anubis b/web/CXM_common.anubis deleted file mode 100644 index e6faa50..0000000 --- a/web/CXM_common.anubis +++ /dev/null @@ -1,297 +0,0 @@ - - *Project* The Anubis Project - *Title* Some common stuff for the web. - - *Copyright* - Copyright © Alain Prouté 2003~2007. - © David RENÉ 2007~2019 - - - *Authors:* - Alain Prouté - David RENÉ - - *Public* - *Name* HTTP_header - *Description* - -transmit tools/basis.anubis -transmit system/string.anubis -read system/logger.anubis -/** - * The type 'HTTP_header' describes HTTP headers, which are just pairs '(name,value)'. - */ - -public type HTTP_header: - http_header( - String name, - String value - ) -. - -public define Maybe(String) - http_header_value - ( - List(HTTP_header) l, - String name - )= - if l is - { - [ ] then failure, - [h . t] then if h is - { - http_header(n, v) then //print("DEBUG: http_header_value --> HEADER = " + n + ":" + v + "\n"); - if insensitive_equal(name, n) then success(v) - else http_header_value(t, name), - } - } -. - -public define String - http_header_value - ( - List(HTTP_header) l, - String name, - String default - )= - if http_header_value(l, name) is - { - failure then default, - success(result) then result - } -. - -public define List(String) - to_List_String - ( - List(HTTP_header) l - )= - map((HTTP_header h) |-> h.name +": "+h.value, l ). - -public define String - to_String - ( - List(HTTP_header) l - )= - join("\n\r",to_List_String(l)). - - -public type HTTP_Info: - http_info - ( - Word32 ip_address, // IP address of the client - String hostname, // hostname requested by the client - String uri, // URI requested by the client - List(HTTP_header) http_headers, // HTTP headers sent by the client - Bool is_https - //One -> String generate_trust_ticket // may be used against denial of - // service attacks - ). - - *Name* Web_arg - *Description* - - The type 'Web_arg' describes 'web arguments'. A web argument is either a pair - '(name,value)' (for example it may be 'web_arg("password","foobar")', if the client - clicks on the submit button of a form containing a password input field named - 'password'), or an uploaded file. In this last case, it is a triplet containing the - name of the file upload input field, the value of this input field (name of the - uploaded file), and the name of the temporary file as saved by the server in its - 'upload temporary directory'; see 'web/http_server.anubis' and the 'upload' Web_item in - 'web/html.anubis'). - -public type Web_arg: - web_arg( - String name, - String value - ), - upload ( - String name, // name of corresponding 'upload' Web_item - String value, // name of uploaded file - String temp_file_path) // temporary file path (relative to server directory) -. - - *Name* Web_arg_value - *Description* - Of course, within the body of a 'web page' operation, you may want to recover the value - of a particular web argument. To that end, use the operation 'web_arg_value', which - takes 2 argument: - - - the list of all web arguments (the operand of the web page operation), - - the name of the argument whose value is wanted. - - This operation has the following return type: - -public type Web_arg_value: - not_found, - found(String value). - - *Name* Web_arg_value - *Description* - If the requested argument name is not found in the list, 'not_found' is - returned. Otherwise, the value returned by 'web_arg_value' has the form 'found(v)', - where 'v' is the value of the argument. - - The operation 'web_arg_value' is defined below. - -public define Web_arg_value - web_arg_value - ( - List(Web_arg) l, - String name - )= - if l is - { - [ ] then not_found, - [h . t] then if h is - { - web_arg(n,v) then - if name=n - then found(v) - else web_arg_value(t,name), - - upload(n,v,tfn) then - if name=n - then found(v) - else web_arg_value(t,name) - } - } -. - -public define Web_arg_value - web_arg_value_not_null - ( - List(Web_arg) lwa, - String name, - ) = - if web_arg_value(lwa, name) is - { - not_found then not_found - found(str) then - if str = "" then - not_found - else - found(str) - }. - - *Ignore* - -public define Maybe((String,String)) - file_upload_value - ( - List(Web_arg) l, - String name - )= - if l is - { - [ ] then failure, - [h . t] then - if h is - { - web_arg(_,_) then file_upload_value(t,name), - upload(n,v,tfn) then - if n = name - then success((v,tfn)) - else file_upload_value(t,name) - } - }. - -public define List((String,String)) - file_upload_value - ( - List(Web_arg) l, - String name, - List((String,String)) new_list - ) = - if l is - { - [ ] then new_list, - [h . t] then if h is - { - web_arg(_,_) then file_upload_value(t,name, new_list), - upload(n,v,tfn) then - if n = name - then file_upload_value(t,name, [(v,tfn) . new_list]) - else file_upload_value(t,name, new_list) - } - }. - - -public type Redirection: - redirect(String required_uri, // URI required by the client - String required_host, // value of 'Host' HTTP header sent by the client - String corresponding_uri). // URI which will be served to the client - -public type Redirections: - redirection_list(List(Redirection) redirections), - redirection_fn((String input_uri, // URI required by the client - String host) -> String f). // value of 'Host' HTTP header sent by the client - - - Now, you may also want to recover web argument values which have been encoded (by - 'web_arg_encode'). In this case, use the following: - -read CXM_web_arg_encode.anubis - - -public define Maybe($T) - decode_web_arg_value - ( - List(Web_arg) l, - String name - ) = - if web_arg_value(l,name) is - { - not_found then failure, - found(v) then web_arg_decode(v) - }. - -public define List(String) - web_arg_list_values - ( - List(Web_arg) l, - String name - ) = - if l is - { - [] then [], - [h . t] then - if h is web_arg(n, v) then - if n = name then - [ v . web_arg_list_values(t, name)] - else - web_arg_list_values(t, name) - else - web_arg_list_values(t, name) - - } - . - -public define String - detect_browser_language - ( - HTTP_Info http_info, - String default_language, - (LogLevel, String) -> One logger - ) = - //logger(logInfo,"Detecting language... "); - if http_header_value(http_info.http_headers, "Accept-Language") is - { - failure then logger(logDebug, "FAILED: unable to find 'Accept-Language' header, use the default one ["+default_language+"]."); default_language , - success(value) then - if split_by_token(value, ',') is - { - [] then logger(logDebug, "FAILED: language header is empty, use the default one ["+default_language+"]."); default_language, - [h . _] then - //TODO real managment of language and country like fr-be for - // belgium french. - //but now we only extract the language and forget the country - if split_by_token(trim(h), '-') is - { - [] then default_language, - [browser_lang . _] then - logger(logDebug, "Language = " + browser_lang);browser_lang - } - } - } -. diff --git a/web/CXM_cookies.anubis b/web/CXM_cookies.anubis deleted file mode 100644 index 7e2ca0c..0000000 --- a/web/CXM_cookies.anubis +++ /dev/null @@ -1,751 +0,0 @@ - - *Project* The Anubis Project - - *Title* Managing Cookies. - - *Copyright* Copyright (c) Alain Prouté 2001. - - - *Author* Alain Prouté - - - - -read tools/basis.anubis -read system/string.anubis -read CXM_common.anubis -read CXM_http_get_common.anubis - - - *Overview* - Cookies are defined in RFC 2109. Here is the corresponding Anubis type: - - Each cookie has an server name (the name of the server who constructed the cookie), a - name, a value, and several attributes. - -public type Cookie: - cookie(String server_name, // of the server who sent the cookie - String name, // of the cookie - String value, // of the cookie - // attributes: - Maybe(String) comment, // cookies may have human readable comments - Maybe(String) domain, // domain name as sent by the server - Int validity, // cookie still valid if this is > now - Maybe(String) path, // server path for which the cookie is valid - Bool secure, // if true, do not send this cookie over an insecure link - Int version). // Cookie version (normally 1: rfc 2109) - - - Cookies are sent by servers through 'Set-Cookie' HTTP headers. The function - 'get_cookies' retrieves a list of cookies from a list of HTTP headers. - -public define List(Cookie) - get_cookies - ( - String server_name, // name of server who sent the cookies - List(HTTP_header) headers // HTTP headers sent by this server - ). - -public define Maybe(Cookie) - find_cookie - ( - String name, - List(Cookie) cookies - ). - - - - - - Normally, this function is used on the list of HTTP headers returned by either - 'http_get' of 'https_get'. - - - Before they can be sent back to their origin server, cookies must be reformated, in - order to produce 'Cookie' HTTP headers: - -public define List(HTTP_header) - reformat_cookies - ( - String server_name, - String uri, - List(Cookie) cookies - ). - - The result of 'reformat_cookies' may be appended to the list of headers given as - argument to 'http_get' or to 'https_get'. - - In the meantime, you may examine and maybe discard cookies, you may 'save' them into a - file, and 'retrieve' them later. - - - - - ------- That all for the public part. ------------------------------------------------- - - - Here is the syntax of a 'Set-Cookie' header (according to RFC 2109): - - set-cookie = "Set-Cookie:" cookies - cookies = 1#cookie - cookie = NAME "=" VALUE *(";" cookie-av) - NAME = token - VALUE = value - value = token | quoted-string - cookie-av = "Comment" "=" value - | "Domain" "=" value - | "Max-Age" "=" value - | "Path" "=" value - | "Secure" - | "Version" "=" 1*DIGIT - - - According to RFC 2616 (obsolating RFC 2068) defining HTTP 1.1, 'control characters' are - 0 to 31 and DEL (127). A 'separator' is one of: - - ( ) < > @ , ; : \ " / [ ] ? = { } 32(space) and 9(tab) " - - Now, a token is a non empty sequence of ASCII characters (0 to 127), but not including - any control character or any separator. As a consequence, characters admissible in a - 'RFC 2616 token' are: - - 33 ! - 35 to 39 # $ & ' - 42 43 * + - 45 46 - . - 48 to 57 0 ... 9 - 65 to 90 A ... Z - 94 to 122 ^ _ ` a ... z - 124 126 | ~ - -define Bool - is_token_char - ( - Word8 c - ) = - if c +< 33 then false else - if c +< 34 then true else - if c +< 35 then false else - if c +< 40 then true else - if c +< 42 then false else - if c +< 44 then true else - if c +< 45 then false else - if c +< 47 then true else - if c +< 48 then false else - if c +< 58 then true else - if c +< 65 then false else - if c +< 91 then true else - if c +< 94 then false else - if c +< 123 then true else - if c +< 124 then false else - if c = 124 then true else - c = 126. - - value char are token added of =, (, ) - -define Bool - is_value_char - ( - Word8 c - ) = - if c +< 33 then false else // space in not allowed in value - if c +< 34 then true else - if c +< 35 then false else // " is not allowed in value - if c +< 44 then true else - if c +< 45 then false else // , is not allowed in value - //if c +< 47 then true else - //if c +< 48 then false else - if c +< 59 then true else - if c +< 60 then false else // ; not allowed in value - //if c +< 62 then true else - //if c +< 65 then false else - //if c +< 91 then true else - //if c +< 94 then false else - //if c +< 123 then true else - //if c +< 124 then false else - //if c = 124 then true else - //c = 126. - if c +< 127 then true - else - false. - - From the grammar, it is clear that atomic entities (called 'tokens' by YACC) are: - - - tokens (in the sens of RFC 2616) some of which have to be recognized as keywords - - quoted strings - - equal sign - - colon - - semi-colon - - Hence, the following type: - -public type Atom: - end_of_input, - error, - comment, - domain, - max_age, - path, - secure, - version, - token(String), - quoted_string(String), - equals, - colon, - semi_colon. - - - variable List(Atom) unput_atoms = []. - -type CookieToolBox: - tool_box(Var(List(Atom)) unput_atoms, - Var(String) input, - Var(Int) index, - Var(String) server_name - ). - -define One - unput_atom - ( - CookieToolBox tbx, - Atom a - ) = - unput_atoms(tbx) <- [a . *unput_atoms(tbx)]. - -define Atom - recognize_keyword - ( - String s - ) = - with l = to_lower(s), - if l = "comment" then comment else - if l = "domain" then domain else - if l = "max-age" then max_age else - if l = "path" then path else - if l = "secure" then secure else - if l = "version" then version else - token(s). - - - variable String input = "". From which cookies will be read. - variable Int index = 0. Current position within 'input'. - -define Maybe(Word8) - next_char - ( - CookieToolBox tbx - ) = - if tbx is tool_box(_, input, index, _) then - if nth(*index,*input) is - { - failure then failure, - success(c) then - index <- *index+1; - success(c) - }. - -define One - unput_char - ( - CookieToolBox tbx - ) = - if tbx is tool_box(_, _, index, _) then - index <- *index-1. - -define Atom - read_token - ( - CookieToolBox tbx, - List(Word8) so_far, // contains at least 1 character - (Word8) -> Bool is_valid_char - ) = - if next_char(tbx) is - { - failure then recognize_keyword(implode(reverse(so_far))), - success(c) then - if is_valid_char(c) - then read_token(tbx,[c . so_far], is_valid_char) - else unput_char(tbx); recognize_keyword(implode(reverse(so_far))) - }. - -define Atom - read_quoted_string - ( - CookieToolBox tbx, - List(Word8) so_far - ) = - if next_char(tbx) is - { - failure then quoted_string(implode(reverse(so_far))), - success(c) then - if c = '\"' - then quoted_string(implode(reverse(so_far))) - else read_quoted_string(tbx,[c . so_far]) - }. - -define Bool - is_blank - ( - Word8 c - ) = - c +=< ' '. - - Reading an atom from the input: - -define Atom - read_atom - ( - CookieToolBox tbx, - ) = - if *unput_atoms(tbx) is - { - [ ] then - if next_char(tbx) is - { - failure then end_of_input, - success(c) then - if is_blank(c) then read_atom(tbx) else // skip blanks - if is_token_char(c) then read_token(tbx,[c], is_token_char) else - if c = '\"' then read_quoted_string(tbx,[]) else - if c = '=' then equals else - if c = ':' then colon else - if c = ';' then semi_colon else - error - }, - [h . t] then - unput_atoms(tbx) <- t; h - }. - -define Atom - read_value - ( - CookieToolBox tbx - ) = - if *unput_atoms(tbx) is - { - [ ] then - if next_char(tbx) is - { - failure then end_of_input, - success(c) then - if is_blank(c) then read_value(tbx) else // skip blanks - if is_value_char(c) then read_token(tbx,[c], is_value_char) else - if c = '\"' then read_quoted_string(tbx,[]) else - if c = ';' then semi_colon else - //println("cookie read value char ["+c+"] is an error"); - error - }, - [h . t] then - unput_atoms(tbx) <- t; h - }. - - Reading an attribute-value pair. - -type AttrVal: - comment(String), - domain(String), - max_age(String), - path(String), - secure, - version(String). - -define String - read_eq_value - ( - CookieToolBox tbx - ) = - with e = read_atom(tbx), - if e is equals then - ( - with a = read_atom(tbx), - if a is token(n) then n else - if a is quoted_string(s) then s else - unput_atom(tbx,a); "" - ) - else unput_atom(tbx,e); "". - - -define Maybe(AttrVal) - read_attr_val - ( - CookieToolBox tbx - ) = - if read_atom(tbx) is semi_colon then - with a = read_atom(tbx), - if a is - { - end_of_input then failure, - error then failure, - comment then success(comment(read_eq_value(tbx))), - domain then success(domain(read_eq_value(tbx))), - max_age then success(max_age(read_eq_value(tbx))), - path then success(path(read_eq_value(tbx))), - secure then success(secure), - version then success(version(read_eq_value(tbx))), - token(_) then unput_atom(tbx,a); failure, - quoted_string(_) then unput_atom(tbx,a); failure, - equals then unput_atom(tbx,a); failure, - colon then unput_atom(tbx,a); failure, - semi_colon then unput_atom(tbx,a); failure, - } - else failure. - - - Getting attributes from a List(AttrVal). - -define Maybe(String) - get_comment - ( - List(AttrVal) l - ) = - if l is - { - [ ] then failure, - [h . t] then if h is comment(c) - then success(c) - else get_comment(t) - }. - -define Maybe(String) - get_domain - ( - List(AttrVal) l - ) = - if l is - { - [ ] then failure, - [h . t] then if h is domain(s) - then success(s) - else get_domain(t) - }. - -define Int - get_validity - ( - List(AttrVal) l - ) = - if l is - { - [ ] then 0, - [h . t] then if h is max_age(a) - then if decimal_scan(a) is - { - failure then 0, - success(n) then n+now - } - else get_validity(t) - }. - -define Maybe(String) - get_path - ( - List(AttrVal) l - ) = - if l is - { - [ ] then failure, - [h . t] then if h is path(p) - then success(p) - else get_path(t) - }. - -define Bool - get_secure - ( - List(AttrVal) l - ) = - if l is - { - [ ] then false, - [h . t] then if h is secure - then true - else get_secure(t) - }. - -define Int - get_version - ( - List(AttrVal) l - ) = - if l is - { - [ ] then 0, - [h . t] then if h is version(v) - then if decimal_scan(v) is - { - failure then 0, - success(n) then n - } - else get_version(t) - }. - - - Reading a cookie: - - variable String server_name = "". - -define Maybe(Cookie) - read_cookie_n_e_v - ( - CookieToolBox tbx, - String name, - String value, - List(AttrVal) so_far - ) = - if read_attr_val(tbx) is - { - failure then - success(cookie( - *server_name(tbx), - name, - value, - get_comment(so_far), - get_domain(so_far), - get_validity(so_far), - get_path(so_far), - get_secure(so_far), - get_version(so_far) - )), - - success(av) then read_cookie_n_e_v(tbx,name,value,[av . so_far]) - }. - -define Maybe(Cookie) - read_cookie_n_e - ( - CookieToolBox tbx, - String name - ) = - with a = read_value(tbx), - if a is token(value) then - //println("read_cookie_n_e name["+name+"] value ["+value+"]"); - read_cookie_n_e_v(tbx,name,value,[]) else - if a is quoted_string(value) then read_cookie_n_e_v(tbx,name,value,[]) else - unput_atom(tbx,a); failure. - -define Maybe(Cookie) - read_cookie_n - ( - CookieToolBox tbx, // bis repetita placent - String name - ) = - with a = read_atom(tbx), - if a is equals - then read_cookie_n_e(tbx,name) - else unput_atom(tbx,a); failure. - - -define Maybe(Cookie) - read_cookie - ( - CookieToolBox tbx - ) = - with a = read_atom(tbx), - if a is token(name) - then read_cookie_n(tbx,name) - else unput_atom(tbx,a); failure. - - -define List(Cookie) - read_cookies - ( - CookieToolBox tbx, - List(Cookie) so_far - ) = - if read_cookie(tbx) is - { - failure then so_far, - success(c) then read_cookies(tbx,[c . so_far]) - }. - - -define List(Cookie) - get_cookies - ( - String svn, - HTTP_header h - ) = - if h is http_header(n,v) then - if to_lower(n) = "set-cookie" - then read_cookies(tool_box(var([]),var(v),var(0),var(svn)),[]) - else []. - -public define List(Cookie) - get_cookies - ( - String server_name, - List(HTTP_header) headers - ) = - if headers is - { - [ ] then [ ], - [h . t] then - append(get_cookies(server_name,h),get_cookies(server_name,t)) - }. - -define List(Cookie) - server_get_cookies - ( - HTTP_header h - ) = - if h is http_header(n,v) then - if to_lower(n) = "cookie" - then read_cookies(tool_box(var([]),var(v),var(0),var("")),[]) - else []. - -public define List(Cookie) - server_get_cookies - ( - // String server_name, - List(HTTP_header) headers - ) = - if headers is - { - [ ] then [ ], - [h . t] then - append(server_get_cookies(h), server_get_cookies(t)) - }. - -public define Maybe(Cookie) - find_cookie - ( - String name, - List(Cookie) cookies - ) - = - if cookies is - { - [] then failure, - [h . t] then - if h is cookie(s, n, v, _, _, _, _, _, _) then - if name = n then success(h) - else find_cookie(name, t) - }. - -public define String - get_cookie_value - ( - String name, - List(Cookie) cookies - ) - = - if find_cookie(name, cookies) is - { - failure then "", - success(c) then if c is cookie(_, _, v, _, _, _, _, _, _) then v - }. - - *** Reformating cookies. ************************************************************** - - Cookies should be resent reformated according to the following grammar (copy-pasted - from RFC 2109): - - cookie = "Cookie:" cookie-version - 1*((";" | ",") cookie-value) - cookie-value = NAME "=" VALUE [";" path] [";" domain] - cookie-version = "$Version" "=" value - NAME = attr - VALUE = value - path = "$Path" "=" value - domain = "$Domain" "=" value - - -define HTTP_header - reformat_cookie - ( - Cookie c - ) = - if c is cookie(sn,n,v,mbc,mbd,vld,mbp,sec,ver) then - http_header("Cookie", - "$Version=" + to_decimal(ver) + - ";" + n + "=\"" + v + "\"" + - if mbp is - { - failure then "", - success(p) then ";$Path=\"" + p + "\"" - } + - if mbd is - { - failure then "", - success(d) then ";$Domain=\"" + d + "\"" - } - ). - - - According to RFC 2109, a cookie may be sent to a server if: - - (1) server name in the cookie is the name of the server, - (2) if 'Path' attribute is present, its value must match the URI, - (3) the cookie is still valid (validity = 0 means indefinitely valid). - - define Bool - path_match - ( - Maybe(String) cookie_path, - String uri - ) = - if cookie_path is - { - failure then true, - success(p) then - - }. - - - Checking if the path matches: - - -define Bool - path_match - ( - Maybe(String) mbp, - String uri - ) = - true. - - - The next function verifies if a cookie satisfies the rules. - -define Bool - may_resend_cookie - ( - String server_name, - String uri, - Cookie c - ) = - if c is cookie(sn,n,v,mbc,mbd,vld,mbp,sec,ver) then - if sn = server_name - then ( - if path_match(mbp,uri) - then ( - if vld = 0 then true else vld > now - ) - else false - ) - else false. - - - The next function reformat all cookies which satisfy the 'resend' rules. - -public define List(HTTP_header) - reformat_cookies - ( - String server_name, - String uri, - List(Cookie) cookies - ) = - if cookies is - { - [ ] then [ ], - [h . t] then - if may_resend_cookie(server_name,uri,h) - then [reformat_cookie(h) . reformat_cookies(server_name,uri,t)] - else reformat_cookies(server_name,uri,t) - }. - - - - - - See test_cookies.anubis for a test of this program. - diff --git a/web/CXM_form.anubis b/web/CXM_form.anubis deleted file mode 100644 index 4737364..0000000 --- a/web/CXM_form.anubis +++ /dev/null @@ -1,998 +0,0 @@ -/* - * Created by PyramIDE. - * User: フランスのトトロ - * Date: 07/12/2014 - * Time: 16:49 - * © David RENÉ - */ - -// ************************************************************************************* -// *** Generic form -// ************************************************************************************* -read tools/basis.anubis -read system/string.anubis -read xlib/web/CXM_common.anubis -read xlib/web/CXM_web_arg_utils.anubis -read xlib/web/CXM_making_a_web_site.anubis -read xlib/web/CXM_html_tooltip.anubis -read xlib/web/CXM_widgets.anubis -read xlib/web/widgets/specialized_elements.anubis - -public type Mandatory: // used to mark fields as mandatory. - mandatory, - non_mandatory. - -public type Width: - small, //10 char - narrow_small, //20 char - narrow, //50 char - wide, //70 char - custom(Int). - -public type FormFieldWidth: - auto, - custom(Int). - -public type CXM_Form_Field: - no_field, // empty field - - //--- title field --------------------------------------------------------------------- - title( - String text - ), - - //--- message field ------------------------------------------------------------------- - message( - String text - ), - - //--- text input field ---------------------------------------------------------------- - input( - List(CoreAttrs) options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - InitialValue init_value, - Width width, - Mandatory mandatory - ), - - input_readonly( - List(CoreAttrs) options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - InitialValue init_value, - Width width - ), - - //--- text area field ----------------------------------------------------------------- - text_area( - List(TextAreaOption) options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - InitialValue init_value, - Width width, - Int height, - Mandatory mandatory - ), - - //--- password input field ------------------------------------------------------------ - password_input( - List(CoreAttrs) options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - InitialValue init_value, - Width width, - Mandatory mandatory), - - //--- phone field ------------------------------------------------------------ - phone_input( - Maybe(List(CoreAttrs)) sms_icon_options, //if there is sms available it's success with the options (generally the js call to edit sms) - List(CoreAttrs) phone_icon_options, - List(CoreAttrs) text_options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - InitialValue init_value, - Phone_Type phone_type, - Width width, - Mandatory mandatory), - - //--- email field ------------------------------------------------------------ - email_input( - List(CoreAttrs) icon_options, - List(CoreAttrs) options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - InitialValue init_value, - Width width, - Mandatory mandatory), - - //--- url field ------------------------------------------------------------ - url_input( - List(CoreAttrs) icon_options, - List(CoreAttrs) options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - InitialValue init_value, - Width width, - Mandatory mandatory), - - //--- hidden field ------------------------------------------------------------ - hidden( - HTML_Id id, - WebArgName web_arg_name, - WebArgValue init_value - ), - //--- explanation field --------------------------------------------------------------- - explain( - String text - ), - - //--- selector field ------------------------------------------------------------------ - selector( - List(CoreAttrs) options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - Int size, - List(String) items, - Maybe(InitialValue) selected, - Mandatory mandatory - ), - - selector_c( - List(CoreAttrs) options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - Int size, - List((List(CoreAttrs), WebArgValue, String)) items, - Maybe(InitialValue) selected, - Mandatory mandatory - ), - - selector_hide_show (List(CoreAttrs) options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - Int size, - List((List(CoreAttrs), WebArgValue, String, HTML_Partial_Content)) items, - Maybe(InitialValue) selected, - Mandatory mandatory), - - //--- checkbox field ------------------------------------------------------------------ - checkbox (List(CoreAttrs) options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - Bool checked, - Mandatory mandatory), - - // the same one, but with the tag on the right of the checkbox - checkboxr( - List(CoreAttrs) options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - Bool checked, - Mandatory mandatory - ), - - //checkbox_hide_show - checkbox_hide_show( - List(CoreAttrs) options, - HTML_Label label, - WebArgName web_arg_name, - Bool checked, - List(CXM_Form_Field) fields - ), - - //--- radio-button field -------------------------------------------------------------- - radio_button( - List(CoreAttrs) options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - WebArgValue web_arg_value, - Bool checked, - Mandatory mandatory - ), - //radio_button_hide_show - radio_button_hide_show( - List(CoreAttrs) options, - HTML_Label label, - WebArgName web_arg_name, - WebArgValue web_arg_value, - Bool checked, - List(CXM_Form_Field) fields - ), - // the same one, but with the tag on the right of the radio_button - radio_buttonr (List(CoreAttrs) options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - WebArgValue web_arg_value, - Bool checked, - Mandatory mandatory), - - radio_button_list( - List(CoreAttrs) options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - List((WebArgValue, String)) web_arg_value, - Maybe(InitialValue) selected, - Mandatory mandatory, - Bool is_wide), - -// //--- fields table -------------------------------------------------------------------- -// fields_table (String tag, -// List(FormField) fields), -// -// //--- fields line --------------------------------------------------------------------- -// fields_line (String tag, -// List(FormField) fields), - one_line_fields (List(CXM_Form_Field) fields), - -// -// //--- preview field ------------------------------------------------------------------- -// preview (String html_text), - - //--- upload field ------------------------------------------------------------------- - upload (List(CoreAttrs) options, - HTML_Label label, - HTML_Id id, - WebArgName name, - Width width, - Mandatory mandatory), - - raw_in_form (HTML_In_Form html), - label_for ( String label, - HTML_Id id, - HTML_In_Form input), - div (List(CoreAttrs), List(HTML_In_Form) contents), - div (List(CoreAttrs), List(CXM_Form_Field) fields), - partial (HTML_Partial_Content p_content), - br, - hr (List(CoreAttrs) options), -// input_with_help (CXM_Form_Field field, -// Maybe(String) help_title, -// String help_text, -// Int width), - - fieldset (List(CoreAttrs) options, - String legend, - List(CXM_Form_Field) fields), - - blank_space, - blank_space (HtmlClass class), - - //--- submit button ------------------------------------------------------------------- - submit (List(CoreAttrs) options, - HtmlClass class, - WEB_Action_Name action_name, - Maybe(String) label, - String button_text, - List((String,String)) extra_operands), - empty. - -// ////////////////////////////////////////////// -// Alternate constructors: - -public define CXM_Form_Field - fieldset - ( - HTML_Id fieldSetId, - List(CXM_Form_Field) fields - ) = - fieldset([id(fieldSetId.id)], "", fields). - -public define CXM_Form_Field - fieldset - ( - List(CXM_Form_Field) fields - ) = - fieldset([], "", fields). - -public define CXM_Form_Field - fieldset - ( - String legend, - List(CXM_Form_Field) fields - ) = - fieldset([], legend, fields). - -public define CXM_Form_Field - input(WebArgName n, InitialValue init_value, Width width) - = input([], no_label, html_Id(n.name), n, init_value, width, non_mandatory). - -public define CXM_Form_Field - input(HTML_Label label, WebArgName n, InitialValue init_value, Width width) - = input([], label, html_Id(n.name), n, init_value, width, non_mandatory). - -public define CXM_Form_Field - input(HTML_Label label, WebArgName n, InitialValue init_value, Width width, Mandatory mand) - = input([], label, html_Id(n.name), n, init_value, width, mand). - -public define CXM_Form_Field - input(HTML_Label label, HTML_Id id, WebArgName n, InitialValue init_value, Width width, Mandatory mand) - = input([], label, id, n, init_value, width, mand). - -public define CXM_Form_Field - input(List(CoreAttrs) options, HTML_Label label, WebArgName n, InitialValue init_value, Width width, Mandatory mand) - = input(options, label, html_Id(n.name), n, init_value, width, mand). - -public define CXM_Form_Field - input_readonly(HTML_Label label, WebArgName n, InitialValue init_value, Width width) - = input_readonly([], label, html_Id(n.name), n, init_value, width). - -public define CXM_Form_Field - password_input(HTML_Label label, WebArgName n, InitialValue init_value, Width width, Mandatory mand) - = password_input([], label, html_Id(n.name), n, init_value, width, mand). - -public define CXM_Form_Field - checkbox(HTML_Label label, WebArgName n, Bool checked, Mandatory mand) - = checkbox([], label, html_Id(n.name), n, checked, mand). - -public define CXM_Form_Field - checkboxr(HTML_Label label, WebArgName n, Bool checked, Mandatory mand) - = checkboxr([], label, html_Id(n.name), n, checked, mand). - -public define CXM_Form_Field - radio_button(HTML_Label label, WebArgName n, WebArgValue value, Bool checked, Mandatory mand) - = radio_button([], label, html_Id(n.name), n, value, checked, mand). - -public define CXM_Form_Field - radio_buttonr(HTML_Label label, WebArgName n, WebArgValue value, Bool checked, Mandatory mand) - = radio_buttonr([], label, html_Id(n.name), n, value, checked, mand). - -public define CXM_Form_Field - submit(WEB_Action_Name action_name, HtmlClass class, Maybe(String) label, String button_text, List((String,String)) extra_operands) - = submit([], class, action_name, label, button_text, extra_operands). - -public define CXM_Form_Field - submit(WEB_Action_Name action_name, Maybe(String) label, String button_text, List((String,String)) extra_operands) - = submit([], htmlClass(""), action_name, label, button_text, extra_operands). - -public define CXM_Form_Field - submit(WEB_Action_Name action_name, Maybe(String) label, String button_text) - = submit([], htmlClass(""), action_name, label, button_text, []). - -public define CXM_Form_Field //Helper for older project wich use only String as Action name - submit(String _action_name, Maybe(String) label, String button_text, List((String,String)) extra_operands) - = submit([], htmlClass(""), action_name(_action_name), label, button_text, extra_operands). - - -public define CXM_Form_Field - upload(HTML_Label label, HTML_Id id, WebArgName name, Width width) - = upload([], label, id, name, width, non_mandatory). - -public define CXM_Form_Field - upload(HTML_Label label, HTML_Id id, WebArgName name, Width width, Mandatory mand) - = upload([], label, id, name, width, mand). - - public define CXM_Form_Field - input_with_help (CXM_Form_Field field, String help_text) - = input_with_help (field, failure, help_text, 250). - - public define CXM_Form_Field - input_with_help (CXM_Form_Field field, String help_text, Int width) - = input_with_help (field, failure, help_text, width). - -public define CXM_Form_Field - ip_input - ( - String label, - HTML_Id id, - WebArgName wan_prefix, - String ip - )= - label_for( - label, - id, - ip_input(id, wan_prefix, ip) - ). - - -public define CXM_Form_Field - partial_ip_input - ( - String label, - HTML_Id id, - WebArgName wan_prefix, - List(String) ip_fixed_part, - String ip - )= - label_for( - label, - id, - partial_ip_input(id, wan_prefix, ip_fixed_part, ip) - ). - -public define CXM_Form_Field - hidden - ( - WebArgName web_arg_name, - WebArgValue value - )= - hidden(html_Id(""), web_arg_name, value). - -public define CXM_Form_Field - hr - = - hr([]) -. - -public define CXM_Form_Field - div - ( - List(CoreAttrs) attrs, - HTML_In_Form content - )= - div(attrs, [content]) -. - -public define CXM_Form_Field - div - ( - HTML_In_Form content - )= - div([], [content]) -. - //--- explanation field --------------------- - -// ////////////////////////////////////////////////////////// - -define (List((List(CoreAttrs), WebArgValue, String)), List(HTML_Partial_Content)) - construct_selector_hide_show - ( - String div_id, - List((List(CoreAttrs), WebArgValue, String, HTML_Partial_Content)) items, - List((List(CoreAttrs), WebArgValue, String)) so_far_1, - List(HTML_Partial_Content) so_far_2, - Int n - ) = - if items is - { - [] then (so_far_1, so_far_2), - [h . t] then - since h is (cores, wav, label, content), - with linked_element = div_id + n, - construct_selector_hide_show(div_id, t, [([data("linked_element", linked_element) . cores], wav, label) . so_far_1], [ partial_content([], div([id(linked_element), style("display: none")], content)) . so_far_2 ], n + 1) - }. - -define (List((List(CoreAttrs), WebArgValue, String)), List(HTML_Partial_Content)) - construct_selector_hide_show - ( - String div_id, - List((List(CoreAttrs), WebArgValue, String, HTML_Partial_Content)) items - ) = construct_selector_hide_show(div_id, items, [], [], 0). - -public define HTML_In_Form - format_div_CXM_Form_Field - ( - List(CXM_Form_Field) field, - List(Web_arg) lwa, - String _class, - Bool b_with_label - ). - - -public define HTML_In_Form - format_CXM_Form_Field - ( - CXM_Form_Field ff, //CXM_Form_Field to format - List(Web_arg) lwa, //web arguments of the session, can be useful for the current drawing - String _class, - Bool b_with_label //if false, no need to show/generate label - ) = - with star = (HTML_Label l, Mandatory m) - |-> - (HTML_Label) - if b_with_label then - if m is - { - mandatory then - if l is - { - no_label then l, - label(str, help) then label(str + "*", help), - } - non_mandatory then l - } - else - no_label - , - pixels = (Width width) - |-> - if width is - { - small then 10, - narrow_small then 20, - narrow then 50, - wide then 70, - custom(n) then n - }, - - - if ff is - { - no_field then - empty, - - title(t) then - literal("

"+t+"

"), - - message(t) then - literal(t), - - input(options, _label, id, wan, default, w, mand) then - text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)), - - input_readonly(options, _label, id, name, init, w) then - text_input_ro([class("in") . options], _label, id, name, init, pixels(w)), - - text_area(options, _label, id, wan, default, w, height, mand) then - text_area([input_attrs([class("in")]) . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w), height), - - password_input(options, _label, id, name, init, w, mand) then - password_input([class("in") . options], star(_label, mand), id, name, init, pixels(w)), - - phone_input(mb_sms_options, icon_options, options, _label, id, wan, default, phone_type, w, mand) then - sequence([ - if mb_sms_options is - { - failure then empty, - success(sms_options) then image([event(onmouseover, "/icons/16x16/send_sms.png")]+sms_options, "/icons/16x16/sms.png", "") - }, - image(icon_options, "/icons/16x16/"+to_Icon(phone_type), ""), - text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)), - ]), - - email_input(icon_options, options, _label, id, wan, default, w, mand) then - sequence([ - image(icon_options, "/icons/16x16/email_edit.png", ""), - text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)), - ]), - - url_input(icon_options, options, _label, id, wan, default, w, mand) then - sequence([ - image(icon_options, "/icons/16x16/url.png", ""), - text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)), - ]), - - hidden(id, name, init) then - hidden(id, name, init), - - explain(t) then - div([class("sub")], literal(t)), - - selector(options, _label, id, wan, size, items, selected, mand) then - if selected is - { - failure then selector([class("in") . options], star(_label, mand), id, wan, size, items), - success(default) then selector([class("in") . options], star(_label, mand), id, wan, size, items, init(get_String(lwa, wan.name, default.value))), - }, - - selector_c(options, _label, id, wan, size, items, selected, mand) then - if selected is - { - failure then selector_c([class("in") . options], star(_label, mand), id, wan, size, items), - success(default) then selector_c([class("in") . options], star(_label, mand), id, wan, size, items, init(get_String(lwa, wan.name, default.value))), - }, - - selector_hide_show(options, _label, id, wan, size, items_with_partial, selected, mand) then - with div_id = generate_random_string(15), - since construct_selector_hide_show(div_id, items_with_partial) is (items, partial_content_list), - sequence([ - selector_c([class("in"), class("cxm_selector_hide_show"), event(onchange, "select_hide_show('" + div_id + "', this);")], star(_label, mand), id, wan, size, reverse(items), if selected is { failure then init(""), success(default) then init(get_String(lwa, wan.name, default.value)) } ), - partial(partial_content(partial_content_list)) - ]), - - checkbox(options, _label, id, wan, checked, mand) then - check_box([class("in") . options], star(_label, mand), id, wan, get_Bool(lwa, wan.name, checked)), - - checkboxr(options, _label, id, wan, checked, mand) then - check_box_r([class("in") . options], star(_label, mand), id, wan, get_Bool(lwa, wan.name, checked)), - - checkbox_hide_show(options, _label, wan, checked, fields) then - with div_id = generate_random_string(15), - sequence([ - check_box([data("show_id", div_id), class("in"), class("cxm_checkbox_hide_show"), event(onclick, "checked_hide_show_element('"+div_id+"', this);")], _label, html_Id("checkbox_"+div_id), wan, get_Bool(lwa, wan.name, checked)), - div([id(div_id), style("display:"+if checked then "block" else "none")], format_div_CXM_Form_Field(fields, lwa, _class, b_with_label)) - ]), - - radio_button(options, _label, id, wan, val, checked, mand) then - radio_button([class("in"), event(onclick, "radio_hide_show_group('"+wan.name+"', this);") . options], star(_label, mand), id, wan, val, get_Bool(lwa, wan.name, checked)), - - radio_button_hide_show(options, _label, wan, val, checked, fields) then - with div_id = generate_random_string(15), - sequence([ - radio_button([data("show_id", div_id), class("in"), class("cxm_radio_hide_show"), event(onclick, "radio_hide_show_group('"+wan.name+"', this);")], _label, html_Id("radio_button_hide_show_"+div_id), wan, val, get_Bool(lwa, wan.name, checked)), - div([id(div_id), style("display:"+if checked then "block" else "none")], format_div_CXM_Form_Field(fields, lwa, _class, b_with_label)) - ]), - - radio_buttonr(options, _label, id, wan, val, checked, mand) then - radio_button_r([class("in") . options], star(_label, mand), id, wan, val, get_Bool(lwa, wan.name, checked)), - - radio_button_list (options, _label, id, wan, items, selected, mand, wide) then - with new_selected = - if get_String(lwa, wan.name) is - { - failure then selected, - success(value) then success(init(value)) - }, - - sequence([ - //literal(""), - div( [class("radiolist")], sequence( - with i = var((Int)-1), - itemclass = if wide then "radiolistitem_wide" else "radiolistitem", - map( ((WebArgValue, String) item) |-> - i <- *i + 1; - if item is (wav, item_label) then - with _id = if id is html_Id(the_id) then html_Id(the_id + "_radio_" + *i), - div([class(itemclass)], radio_button_r(options, label(item_label), _id, wan, wav, - if new_selected is success(v) then wav.value = v.value else false)), - items)) - ), - ]), - one_line_fields(fields) then - table([nude, class("form_one_line")],[row([], - map((CXM_Form_Field ff2) |-> cell([],format_CXM_Form_Field(ff2, lwa, _class, b_with_label)),fields))]) - , - - upload(options, _label, id, name, w, mand) then - file_upload([class("in") . options], star(_label, mand), id, name, pixels(w)), - - raw_in_form(html) then html, -// div([class("in")], html), - label_for(label, id, input) then - sequence([ - if id is html_Id(_id) then - literal(""), - input - ]), - - div(options, e) then div(options, e), - div(options, fields)then div(options, format_div_CXM_Form_Field(fields, lwa, _class, b_with_label)), - partial(p_content) then partial(p_content), - br then br, - hr(opts) then hr(opts), -// input_with_help(input, help_title, help_text, width) then -// sequence([ -// format_CXM_Form_Field(input, lwa, html_tooltip(force_String(help_title), help_text, width)), -// ]), - - fieldset(options, legend, fields) then - sequence([ - literal(""), - literal(if length(legend) > 0 then "" + legend + "" else ""), - format_div_CXM_Form_Field(fields, lwa, _class, b_with_label), - literal("") - ]), - - blank_space then - div([class("blank_space")], literal(" ")), - - blank_space(htmlClass) then - div([class(htmlClass.class)], literal(" ")), - - submit(attrs, htmlClass, action_name, Maybe(String) mb_label, button_text, extra_operands) then - actioner( same, // TODO change this to allow external URL - if mb_label is - { - failure then same, - success(n) then same(n) - }, - submit(attrs + [class(htmlClass.class + " cxm_submit")], button_text), - action_name, - extra_operands - ), - empty then literal("") - }. - - public define HTML_In_Form - format_div_CXM_Form_Field - ( - CXM_Form_Field field, - List(Web_arg) lwa, - String _class, - Bool b_with_label - )= - if field is empty then - empty - else if field is no_field then - empty - else if field is hidden(id, name, init) then - format_CXM_Form_Field(field, lwa, _class, b_with_label) - else if field is br then - format_CXM_Form_Field(field, lwa, _class, b_with_label) - else if field is text_area(options, _label, id, wan, default, w, height, mand) then - div([], format_CXM_Form_Field(field, lwa, _class, b_with_label)) - else - div([class(_class)], format_CXM_Form_Field(field, lwa, _class, b_with_label)) -. - - - -public define HTML_In_Form - format_div_CXM_Form_Field - ( - List(CXM_Form_Field) fields, - List(Web_arg) lwa, - String _class, - Bool b_with_label - )= - //println("format_div_CXM_Form_Field"); - sequence( map((CXM_Form_Field field) - |-> - //with css_line = if line = 0 then " odd_line" else " even_line", - //println("class "+css_line+" line "+line); - if field is empty then - empty - else if field is no_field then - empty - else if field is hidden(id, name, init) then - format_CXM_Form_Field(field, lwa, _class, b_with_label) - else if field is br then - format_CXM_Form_Field(field, lwa, _class, b_with_label) - else if field is text_area(options, _label, id, wan, default, w, height, mand) then - div([class(_class)], format_CXM_Form_Field(field, lwa, _class, b_with_label)) - else - div([class(_class)], format_CXM_Form_Field(field, lwa, _class, b_with_label)) - , fields)) -. - -public define HTML_In_Form - to_HTML_In_Form - ( - List(CXM_Form_Field) fields, - List(Web_arg) lwa, - String _class, - Bool b_with_label - )= - format_div_CXM_Form_Field(fields, lwa, _class, b_with_label) -. - - "form_field aligned" - - public define HTML_In_Form - fieldset - ( - CXM_Form_Field field, - List(Web_arg) lwa, - String _class, - Bool b_with_label - )= - fieldset([field], lwa, _class, b_with_label) -. - - -public define HTML_In_Form - to_HTML_In_Form - ( - List(CXM_Form_Field) fields, - String _class, - Bool b_with_label - )= - to_HTML_In_Form(fields, [], _class, b_with_label). - -public define HTML_In_Form - to_HTML_In_Form - ( - List(CXM_Form_Field) fields, - List(Web_arg) lwa - )= - to_HTML_In_Form(fields, lwa, "form_field aligned", true) -. - -public define HTML_In_Form - to_HTML_In_Form - ( - CXM_Form_Field field, - List(Web_arg) lwa - )= - to_HTML_In_Form([field], lwa, "form_field aligned", true) -. - -public define HTML_In_Form - to_HTML_In_Form - ( - List(CXM_Form_Field) fields - )= - to_HTML_In_Form(fields, [], "form_field aligned", true) -. - -public define HTML_Off_Form - cxm_form - ( - HTML_Id form_Id, - List(CoreAttrs) options, - WEB_Action_Name action, - List((String,String)) extra_ops, - List(Web_arg) lwa, - List(CXM_Form_Field) fields, - String _class, - Bool b_with_label - ) = - form( - form_Id, - [class("cxm_form") . options], - action, - extra_ops, - format_div_CXM_Form_Field(fields, lwa, _class, b_with_label) - ). - -public define HTML_Off_Form -/* older manner to call CXM_form with action as String. - * this function only exists for compatibility with older projects. Please consider - * to use the above function with WEB_Action_Name instead of String -*/ - cxm_form - ( - HTML_Id form_Id, - List(CoreAttrs) options, - String action, //older manner to call action with String - List((String,String)) extra_ops, - List(Web_arg) lwa, - List(CXM_Form_Field) fields, - String _class, - Bool b_with_label - ) = - - form( - form_Id, - [class("cxm_form") . options], - action_name(action), - extra_ops, - format_div_CXM_Form_Field(fields, lwa, _class, b_with_label) - ). - -public define HTML_Off_Form - cxm_form - ( - String form_name, - List(CoreAttrs) options, - WEB_Action_Name action, - List((String,String)) extra_ops, - List(Web_arg) lwa, - List(CXM_Form_Field) form_fields, - String _class, - Bool b_with_label - )= - cxm_form(html_Id(form_name), options, action, extra_ops, lwa, form_fields, _class, b_with_label). - -public define HTML_Off_Form - cxm_form - ( - String form_name, - List(CoreAttrs) options, - WEB_Action_Name action, - List((String,String)) extra_ops, - List(Web_arg) lwa, - List(CXM_Form_Field) form_fields - )= - cxm_form(form_name, options, action, extra_ops, lwa, form_fields, "form_field aligned", true) -. - -public define HTML_Off_Form - cxm_form - ( - String form_name, - List(CoreAttrs) options, - String action, - List((String,String)) extra_ops, - List(Web_arg) lwa, - List(CXM_Form_Field) form_fields, - - Bool b_with_label - )= - cxm_form(html_Id(form_name), options, action_name(action), extra_ops, lwa, form_fields, "form_field aligned", b_with_label) -. - -public define HTML_Off_Form - cxm_form - ( - String form_name, - List(CoreAttrs) options, - String action, - List((String,String)) extra_ops, - List(Web_arg) lwa, - List(CXM_Form_Field) form_fields - )= - cxm_form(html_Id(form_name), options, action_name(action), extra_ops, lwa, form_fields, "form_field aligned", true) -. - -public define HTML_Off_Form - cxm_form - ( - String form_id, - List(CoreAttrs) options, - List(HTML_In_Form) fields, - String _class - ) = - cxm_form(html_Id(form_id), options, action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields), _class, true ) -. - -public define HTML_Off_Form - cxm_form - ( - String form_id, - List(CoreAttrs) options, - List(HTML_In_Form) fields - ) = - cxm_form(html_Id(form_id), options, action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields), "form_field aligned", true ) -. - -public define HTML_Off_Form - cxm_form - ( - String form_id, - List(CoreAttrs) options, - List(Web_arg) lwa, - List(CXM_Form_Field) fields, - String _class, - Bool b_with_label - ) = - cxm_form(html_Id(form_id), options, action_name(""), [], lwa, fields, _class, b_with_label). - -public define HTML_Off_Form - cxm_form - ( - String form_id, - List(HTML_In_Form) fields, - String _class - ) = - cxm_form(html_Id(form_id), [], action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields), _class, true ). - -public define HTML_Off_Form - cxm_form - ( - String form_id, - List(Web_arg) lwa, - List(CXM_Form_Field) fields, - String _class - ) = - cxm_form(form_id, [], lwa, fields, _class, true). - -public define HTML_Off_Form - cxm_form - ( - String form_id, - List(Web_arg) lwa, - List(CXM_Form_Field) fields, - ) = - cxm_form(form_id, [], lwa, fields, "form_field aligned", true). - -public define HTML_Off_Form - cxm_form - ( - String form_id, - List(CoreAttrs) options, - List(CXM_Form_Field) fields, - ) = - cxm_form(form_id, options, [], fields, "form_field aligned", true). - -public define HTML_Off_Form - cxm_form - ( - String form_id, - List(CXM_Form_Field) fields, - String _class - ) = - cxm_form(html_Id(form_id), [], action_name(""), [], [], fields, _class, true). - -public define HTML_Off_Form - cxm_form - ( - String form_id, - List(CXM_Form_Field) fields - ) = - cxm_form(html_Id(form_id), [], action_name(""), [], [], fields, "form_field aligned", true). diff --git a/web/CXM_html_tooltip.anubis b/web/CXM_html_tooltip.anubis deleted file mode 100644 index 15a5a47..0000000 --- a/web/CXM_html_tooltip.anubis +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Created by PyramIDE. - * User: フランスのトトロ - * Date: 07/12/2014 - * Time: 17:12 - * © David RENÉ - */ - -read tools/basis.anubis - -read xlib/web/CXM_common.anubis -read xlib/web/CXM_making_a_web_site.anubis - -//public type HTML_Off_Form:... - - public define HTML_Off_Form - html_tooltip - ( - String title, - String keyword, - ) = - literal(""). - - actioner(same,same, link([id("help_" + keyword), class("jTip jTip_help"), attr("target", "_blank")], " ", success(title)), "ajax_show_tooltip", [("tooltip_id", keyword)], []). - - public define HTML_Off_Form - html_tooltip - ( - String title, - String keyword, - Int width, - ) = - literal(""). - - actioner(same,same, link([id("help_" + keyword), class("jTip jTip_help"), attr("target", "_blank")], " ", success(title)), "ajax_show_tooltip", [("tooltip_id", keyword), ("width", to_decimal(width))], []). - - public define HTML_In_Form - html_tooltip - ( - String title, - String keyword, - ) = - literal(""). - - actioner(same,same, link([id("help_" + keyword), class("jTip jTip_help"), attr("target", "_blank")], " ", success(title)), "ajax_show_tooltip", [("tooltip_id", keyword)], []). - - public define HTML_In_Form - html_tooltip - ( - String title, - String keyword, - Int width, - ) = - literal(""). - - actioner(same,same, link([id("help_" + keyword), class("jTip jTip_help"), attr("target", "_blank")], " ", success(title)), "ajax_show_tooltip", [("tooltip_id", keyword), ("width", to_decimal(width))], []). - - public define HTML_Off_Form - html_tooltip_ext - ( - String title, - String keyword, - String class_suffix - ) = - actioner(same,same, link([id("help_" + keyword), class("jTip jTip_"+class_suffix), attr("target", "_blank")], " ", success(title)), "ajax_show_tooltip", [("tooltip_ext", keyword)], []). - - public define HTML_Off_Form - html_tooltip_ext - ( - String title, - String keyword, - String class_suffix, - List((String, String)) ext_args - ) = - with extra_args = format_extra_operands(ext_args), - literal(""). - - actioner(same,same, link([id("help_" + keyword), class("jTip jTip_"+class_suffix), attr("target", "_blank")], " ", success(title)), "ajax_show_tooltip", [("tooltip_ext", keyword)] + ext_args, []). - - public define HTML_In_Form - html_tooltip_ext - ( - String title, - String keyword, - String class_suffix - ) = - actioner(same,same, link([id("help_" + keyword), class("jTipu jTip_"+class_suffix), attr("target", "_blank")], " ", success(title)), "ajax_show_tooltip", [("tooltip_ext", keyword)], []). - - public define HTML_In_Form - html_tooltip_ext - ( - String title, - String keyword, - String class_suffix, - List((String, String)) ext_args - ) = - with extra_args = format_extra_operands(ext_args), - literal(""). - - public define HTML_In_Form - html_tooltip_ext - ( - String title, - String extend_type, - String class_suffix, - List((String, String)) ext_args - ) = - with extra_args = format_extra_operands(ext_args), - literal(""). - - - href=\"/?a=ajax_show_tooltip&tooltip_id="+keyword+"\" id=\"help_"+keyword+HELP_HMS_MODE" class="jTip jTip_help" target="_blank" name="Aide sur la fonctionnalité 'No Limit'"> "). - - actioner(same,same, link([id("help_" + keyword), class("jTip jTip_"+class_suffix), attr("target", "_blank")], " ", success(title)), "ajax_show_tooltip", [("tooltip_ext", keyword)] + ext_args, []). diff --git a/web/CXM_http_get_common.anubis b/web/CXM_http_get_common.anubis deleted file mode 100644 index a29a382..0000000 --- a/web/CXM_http_get_common.anubis +++ /dev/null @@ -1,305 +0,0 @@ - - *Project* The Anubis Project - - *Title* Getting a document from the Web. - - *Copyright* Copyright (c) Alain Prouté 2001. - - - *Author* Alain Prouté - - - - This file contains the types and functions which are common to 'http_get' and - 'https_get'. - -read tools/basis.anubis -read tools/findstring.anubis -read system/string.anubis -read CXM_common.anubis - read web/html.anubis - - - - Body of HTTP requests may also contain name-value pairs. We call them HTTP arguments: - -public type HTTP_argument: - http_argument(String name, String value). - - - - We begin by several simple tools. - - 'crlf' and 'crlfcrlf' are defined in 'basis.anubis'. - -public define Maybe(Int) - has_double_crlf - ( - String s, - ) = - find(crlfcrlf,s,0). - - - - - Formatting a list of HTTP arguments. - -public define String - format_http_args - ( - List(HTTP_argument) l - ) = - if l is - { - [ ] then "", - [h . t] then - if t is - { - [ ] then if h is http_argument(n,v) then n + "=" + v, - [_ . _] then if h is http_argument(n,v) then n + "=" + v + "&" + format_http_args(t) - } - }. - - - - Formatting the headers. - -public define String - format_headers - ( - List(HTTP_header) headers - ) = - if headers is - { - [ ] then "", - [h . t] then if h is http_header(n,v) then - n + ": " + v + crlf + format_headers(t) - }. - - - - - -//public define String -// format -// ( -// DNS_Result r -// ) = -// if r is -// { -// host_not_found then "host not found", -// no_address_found then "no address found for this host", -// try_again then "DNS server is busy, try again later", -// non_recoverable_error then "non recoverable DNS error", -// ok(n) then should_not_happen("ok") // should never happen -// }. - - -public define String - format - ( - NetworkConnectError e - ) = - if e is - { - cannot_create_the_socket then "cannot create the socket", - address_port_not_available then "address:port not available", - connection_refused then "connection refused", - network_unreachable then "network is unreachable", - address_port_already_in_use then "address:port already in use", - out_of_time then "out of time" - }. - -public define String - format - ( - SSLConnectError e - ) = - if e is - { - tcp_error(nce) then format(nce), - cannot_create_SSL_object then "cannot create SSL object", - cannot_connect_under_SSL then "cannot connect under SSL", - cannot_trust_server_certificate then "cannot trust server certificate" - }. - - - - The next function empties the standard input (the keybord normally). - -define One - empty_stdin - ( - One dummy - ) = - if *stdin is - { - failure then unique, - success(c) then - if c = 10 - then unique - else empty_stdin(dummy) - }. - - - The next function returns true if the user answers Y or y. - -public define Bool - yes - = - if *stdin is - { - failure then should_not_happen(false), // this can never happen, because stdin is never closed - success(c) then - empty_stdin(unique); - (c = 'Y' | c = 'y') - }. - - - - Separating the server name from the port. - -public define (String,Word32) - separate_name_port - ( - String server_name, - Word32 default_port - ) = - if find(":",server_name,0) is - { - failure then (server_name,default_port), - success(n) then - (substr(server_name,0,n), - if decimal_scan(substr(server_name,n+1,length(server_name)-n-1)) is - { - failure then default_port, - success(p) then truncate_to_Word32(p) - }) - }. - - - - - - Separating the headers. The headers are comming in the form of a unique string. They - should be put in the form of a list of pairs of strings (one list element per header). - - We do that in two steps. (1) separate the headers into a list of strings (one per - header), and (2) separate each string into a pair of strings (name,value). - - -define HTTP_header - separate_header - ( - String header, - Int i - ) = - if nth(i,header) is - { - failure then http_header(header,""), - success(c) then - if c = ':' // separator - then http_header(substr(header,0,i),substr(header,i+1,length(header)-i-1)) - else separate_header(header,i+1) - }. - - - Headers are separated from each other by CRLF not followed by a blank character. - -define List(HTTP_header) - separate_headers - ( - String headers, - Int start, - ) = - if find("\r\n",headers,start) is - { - failure then [separate_header(substr(headers,start,length(headers)-start),0)], - success(end) then - [separate_header(substr(headers,start,end-start),0) . separate_headers(headers,end+2)] - }. - -public define List(HTTP_header) - separate_headers - ( - String headers, - ) = - separate_headers(headers,0). - - -public define One - print_headers - ( - List(HTTP_header) headers - ) = - if headers is - { - [ ] then unique, - [h . t] then - if h is http_header(l,r) then - print(" "); print(l); print(": "); print(r); print("\n"); print_headers(t) - }. - - -//public define Word8 -// force_nth -// ( -// Int n, -// String s -// ) = -// if nth(n,s) is -// { -// failure then 0, -// success(c) then c -// }. - - -public define List(HTTP_header) - get_headers - ( - List(String) args - ) = - if args is - { - [ ] then [ ], - [h . t] then if nth(0,h) is - { - failure then should_not_happen([]), - success(c) then if c = '=' - then if t is - { - [ ] then [http_header(substr(h,1,length(h)-1),"")], - [u . v] then [http_header(substr(h,1,length(h)-1),u) . get_headers(v)] - } - else get_headers(t) - } - }. - -public define List(HTTP_argument) - get_arguments - ( - List(String) args - ) = - if args is - { - [ ] then [ ], - [h . t] then if nth(0,h) is - { - failure then should_not_happen([]), - success(c) then if c = '=' - then if t is - { - [ ] then [ ], - [u . v] then get_arguments(v) - } - else if c = '-' - then get_arguments(t) - else if t is - { - [ ] then [http_argument(h,"")], - [u . v] then [http_argument(h,u) . get_arguments(v)] - } - } - }. - - diff --git a/web/CXM_jquery.anubis b/web/CXM_jquery.anubis deleted file mode 100644 index 689c91e..0000000 --- a/web/CXM_jquery.anubis +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Created by PyramIDE. - * User: Jeremy - * Date: 21/08/2012 - * Time: 16:52 - * - */ - -transmit xlib/web/CXM_making_a_web_site.anubis -read xlib/web/load_content.anubis -read tools/printable_tree.anubis -read tools/basis.anubis - -/* jQuery Actioner type */ -public type JQuery_Actioner_type: - jqform ( String form, WEB_Action_Name name, List((String,String)) extra_ops), - jqformload ( String form, String target, WEB_Action_Name name, List((String,String)) extra_ops), - jqlink ( WEB_Action_Name name, List((String,String)) extra_ops), - jqflink ( String link), - jqscript( String script), - jqload ( String target, WEB_Action_Name name, List((String,String)) extra_ops) -. - -public define JQuery_Actioner_type jqlink(WEB_Action_Name name) = jqlink(name, []). -public define JQuery_Actioner_type jqlink(String name) = jqlink(action_name(name), []). -public define JQuery_Actioner_type jqform(String form) = jqform(form, no_action, []). - -/* jQuery Actioner */ -public type JQuery_Actioner: - jQuery_actioner(Actioner_Target target, JQuery_Actioner_type type). //, String url_or_form_id_or_script - -/* jQuery Selector - http://api.jquery.com/category/selectors/ */ -public type JQuerySelector: - element(HTML_Id id), - element_class(String name), - childs(HTML_Id id). - -define String - jquery_button_get_onclick_action_window_options - ( - List(Other_Window_Option) options, - String formated_options - ) - = - //if there is already formated_options add a comma + space between the options - with comma = if formated_options="" then "" else ", ", - - if options is - { - [ ] then formated_options, - [ c . t ] then - if c is - { - resizable then jquery_button_get_onclick_action_window_options( - t, formated_options+ comma + "resizable=yes"), - - scrollbars then jquery_button_get_onclick_action_window_options( - t, formated_options+ comma + "scrollbars=yes"), - - width(w) then jquery_button_get_onclick_action_window_options( - t, formated_options+ comma + "width="+w), - - height(h) then jquery_button_get_onclick_action_window_options( - t, formated_options+ comma + "height="+h) - } - } - . - -public define String - jquery_button_get_onclick_action - ( - JQuery_Actioner actioner - ) - = - if actioner is jQuery_actioner(target, act_type) then - if target is - { - same then - if act_type is - { - jqform(form, control_action, extra_ops) then - - if control_action is - { - no_action then "", //will use the default action defined in form - controller_action(ctrl, action) then - "$('#"+form+"').get(0).setAttribute('action','/?aws_controller="+ctrl+"&aws_action="+action+format_extra_operands(extra_ops)+"');\n" - action_name(action) then - "$('#"+form+"').get(0).setAttribute('action','/?aws_action="+action+"');", - url(url) then - "$('#"+form+"').get(0).setAttribute('action','"+url+"');", - }+ - "$('#"+form+"').submit();\n", - jqformload(form_id, target_id, web_action, extra_args) then - "CalexiumToolBox.jq_form_submit_and_load('"+form_id+"', '"+format_web_action_name(web_action, extra_args)+"', '"+target_id+"');\n" - jqlink(control_action, extra_ops) then - if control_action is - { - no_action then "", - controller_action(ctrl, action) then "document.location='/?aws_controller="+ctrl+"&aws_action="+action+format_extra_operands(extra_ops)+"';", - action_name(action) then "document.location='/?aws_action="+action+"';", - url(url) then "document.location='"+url+"';", - } - jqflink(link) then "document.location='"+link+"';", - jqscript(script) then script - jqload(target_id, web_action, extra_args) then load_content(target_id, web_action, extra_args, false) - }, - same(label) then - if act_type is - { - jqform(form, control_action, extra_ops) then - if control_action is - { - no_action then "", //will use the default action defined in form - controller_action(ctrl, action) then - "$('#"+form+"').get(0).setAttribute('action','/?aws_c="+ctrl+"&aws_a="+action+format_extra_operands(extra_ops)+"');\n" - action_name(action) then - "$('#"+form+"').get(0).setAttribute('action','/?aws_action="+action+"');", - url(url) then - "$('#"+form+"').get(0).setAttribute('action','"+url+"');", - }+ - "$('#"+form+"').submit();\n", - jqformload(form_id, target_id, web_action, extra_args) then - "CalexiumToolBox.jq_form_submit_and_load('"+form_id+"', '"+format_web_action_name(web_action, extra_args)+"', '"+target_id+"');\n" - jqlink(control_action, extra_ops) then - if control_action is - { - no_action then "", - controller_action(ctrl, action) then "document.location='/?aws_controller="+ctrl+"&aws_action="+action+format_extra_operands(extra_ops)+"';", - action_name(action) then "document.location='/?aws_action="+action+format_extra_operands(extra_ops)+"';", - url(url) then "document.location='"+url+"';", - } - jqflink(link) then "document.location='"+link+"';", - jqscript(script) then script - jqload(target_id, web_action, extra_args) then load_content(target_id, web_action, extra_args, false) - }, - other(window_name, window_options) then - if act_type is - { - jqform(form, control_action, extra_ops) then //il s'agit d'une soumision d'un formulaire => cela se fait uniquement dans la même fenêtre ! - if control_action is - { - no_action then "", //will use the default action defined in form - controller_action(ctrl, action) then - "$('#"+form+"').get(0).setAttribute('action','/?aws_controller="+ctrl+"&aws_action="+action+format_extra_operands(extra_ops)+"');\n" - action_name(action) then - "$('#"+form+"').get(0).setAttribute('action','/?aws_action="+action+"');", - url(url) then - "$('#"+form+"').get(0).setAttribute('action','"+url+"');", - }+ - "$('#"+form+"').submit();\n", - jqformload(form_id, target_id, web_action, extra_args) then - "CalexiumToolBox.jq_form_submit_and_load('"+form_id+"', '"+format_web_action_name(web_action, extra_args)+"', '"+target_id+"');\n" - jqlink(control_action, extra_ops) then - if control_action is - { - no_action then "", - controller_action(ctrl, action) then - "window.open('aws_controller="+ctrl+"&aws_action="+action+format_extra_operands(extra_ops)+"', '"+window_name+"', '"+jquery_button_get_onclick_action_window_options(window_options, "")+"');", - //"document.location='/?aws_controller="+ctrl+"&aws_action="+action+"';", - action_name(action) then - "window.open('"+action+format_extra_operands(extra_ops)+"', '"+window_name+"', '"+jquery_button_get_onclick_action_window_options(window_options, "")+"');", - url(url) then "document.location='"+url+"';", - } - jqflink(link) then "document.location='"+link+"';", - jqscript(script) then script - jqload(target_id, web_action, extra_args) then load_content(target_id, web_action, extra_args, false) - } - }. - -public define String - format_jquery_selector - ( - JQuerySelector selector - ) = - if selector is - { - element(html_id) then - if html_id is html_Id(id) then "'#" + id + "'", - - element_class(name) then - "'." + name + "'", - - childs(html_id) then - if html_id is html_Id(id) then "'#" + id + " > *'" - }. - -/* */ -public define Script - jquery_ready - ( - String code //javascript code to execute when the document is ready - )= - script("text/javascript","$(document).ready(function(){"+code+"});"). - -public define String - jquery_ready - ( - String code //javascript code to execute when the document is ready - )= - "$(document).ready(function(){"+code+"});". - -/* jQuery default js files */ -define List(HTML_Head_Tag) - jquery_defaults - = - [ - js(js_file("/js/jquery/jquery-1.12.4.min.js")), - js(js_file("/js/jquery/jquery-ui-1.11.4/jquery-ui.min.js")), - ]. - -/* Initialize jQuery in compatiblity mode with jQueryUI */ -public define List(HTML_Head_Tag) - jquery_init - ( - String web_dir, - String theme_name - ) - = - if file_exists(web_dir+"/public/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.min.css") then - [ css(css_file("/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.min.css")), - css(css_file("/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.structure.min.css")), - css(css_file("/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.theme.min.css")) . jquery_defaults ] - else - println("Jquery Theme not found "+web_dir+"/public/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.min.css"); - //TODO change to real default jquery ui css - [ css(css_file("/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.min.css")) . jquery_defaults ] - . diff --git a/web/CXM_json.anubis b/web/CXM_json.anubis deleted file mode 100644 index 0164142..0000000 --- a/web/CXM_json.anubis +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Created by PyramIDE. - * User: ricard - * Date: 18/08/2008 - * Time: 08:12 - * - * - */ - -read tools/basis.anubis -read tools/printable_tree.anubis -transmit web/mime.anubis - -transmit xlib/extensions/json.anubis - -public type JsonMember:... - - -public type JsonValue: - json_object(List(JsonMember)), - json_array(List(JsonValue)), - json_int(Int value), - json_float(Float value, Int precision), - json_string(String value), - json_bool(Bool value), - json_null. - - -public type JsonMember: - json_member(String name, - JsonValue value). - -public define Printable_tree - _format_json - ( - JsonValue json - ). - -public define Printable_tree - _format_json - ( - Library json_lib, - JsonValue json - ). -//------------------------------- -// helpers - -public define JsonValue - json_object - ( - String type_name, - List(JsonMember) members - )= - json_object([json_member("obj_type", json_string(type_name)) . members]). - -public define JsonMember - json_member - ( - String name, - List(JsonMember) value, - ) = - json_member(name, json_object(value)). - - -public define JsonMember - json_member - ( - String name, - List(JsonValue) value, - ) = - json_member(name, json_array(value)). - -public define JsonMember - json_member - ( - String name, - Int value, - ) = - json_member(name, json_int(value)). - -public define JsonMember - json_member - ( - String name, - Float value, - Int precision, - ) = - json_member(name, json_float(value, precision)). - -public define JsonMember - json_member - ( - String name, - String value, - ) = - json_member(name, json_string(value)). - -public define JsonMember - json_member - ( - String name, - Bool value, - ) = - json_member(name, json_bool(value)). - -public define JsonMember - json_null - ( - String name, - ) = - json_member(name, json_null). - -public define JsonValue - to_json_array - ( - List(String) list_str - )= - json_array(map((String str) |-> json_string(str), list_str)) -. - -//------------------------------------------- -// Outputing Json to Printable_tree - -define List(Word8) - _format_json_esc - ( - List(Word8) original, - List(Word8) new_string, - ) = - if original is - { - [] then ['\"' . new_string], //add trailing double quotes - [h . t] then - if (h >=+ 32 & h +=< 33) | (h >=+ 35 & h +=< 91) | h >=+ 93 then // Allowed characters for JSON see RFC4627 + " ' " Why ' ??? - _format_json_esc(t, [h . new_string]) - else if h = '\n' then _format_json_esc(t, ['n', '\\' . new_string]) - else if h = '\r' then _format_json_esc(t, ['r', '\\' . new_string]) - else if h = '\t' then _format_json_esc(t, ['t', '\\' . new_string]) - else if h = 0x08 then _format_json_esc(t, ['b', '\\' . new_string]) //Backspace - else _format_json_esc(t, [h, '\\' . new_string]) - }. - -public define String - format_json_esc - ( - String original, - ) = - implode(reverse(_format_json_esc(explode(original), ['\"'],))). - - -public define Printable_tree - format_json - ( - JsonValue json - ). - -public define Printable_tree - to_javascript - ( - JsonValue json - ). - -public define Printable_tree - format_json_member - ( - JsonMember member - ) = - if member is json_member(name, value) then - [ "\"", name, "\":" . _format_json(value) ]. - -public define Printable_tree - format_json_member - ( - Library json_lib, - JsonMember member - ) = - if member is json_member(name, value) then - [ "\"", name, "\":" . _format_json(json_lib, value) ]. - -public define Printable_tree - json_member_to_js - ( - JsonMember member - ) = - if member is json_member(name, value) then - [ "\"", name, "\":" . to_javascript(value) ]. - -define Printable_tree - format_json_object - ( - List(JsonMember) members - ) = - if members is - { - [] then [], - [h . t] then [ format_json_member(h), (if t is [] then "" else ",") . format_json_object(t) ] - }. - -define Printable_tree - format_json_object - ( - Library json_lib, - List(JsonMember) members - ) = - if members is - { - [] then [], - [h . t] then [ format_json_member(json_lib, h), (if t is [] then "" else ",") . format_json_object(json_lib, t) ] - }. - -define Printable_tree - json_object_to_js - ( - List(JsonMember) members - ) = - if members is - { - [] then [], - [h . t] then [ json_member_to_js(h), (if t is [] then "" else ",") . json_object_to_js(t) ] - }. - -define Printable_tree - format_json_array - ( - Library json_lib, - List(JsonValue) values - ) = - if values is - { - [] then [], - [h . t] then [ _format_json(json_lib, h), (if t is [] then "" else ",") . format_json_array(json_lib, t) ] - }. - -define Printable_tree - format_json_array - ( - List(JsonValue) values - ) = - if values is - { - [] then [], - [h . t] then [ _format_json(h), (if t is [] then "" else ",") . format_json_array(t) ] - }. - -public define Printable_tree - _format_json - ( - Library json_lib, - JsonValue json - ) = - if json is - { - json_object(members) then [ "{", format_json_object(json_lib, members), "}" . [] ], - json_array(values) then [ "[", format_json_array(json_lib, values), "]" . [] ], - json_int(i) then int_pt(i, []), - json_float(f, p) then str_pt(float_to_string(f, p), []), - json_string(s) then if s ="" then str_pt("\"\"", []) else str_pt(to_JSON_String(json_lib, s), []), - json_bool(b) then str_pt(if b then "true" else "false", []), - json_null then str_pt("null", []) - }. - -public define Printable_tree - _format_json - ( - JsonValue json - ) = - if json is - { - json_object(members) then [ "{", format_json_object(members), "}" . [] ], - json_array(values) then [ "[", format_json_array(values), "]" . [] ], - json_int(i) then int_pt(i, []), - json_float(f, p) then str_pt(float_to_string(f, p), []), - json_string(s) then str_pt(format_json_esc(s), []), - json_bool(b) then str_pt(if b then "true" else "false", []), - json_null then str_pt("null", []) - }. - -public define Printable_tree - format_json - ( - JsonValue json - ) = - //try to use adl version of json escape string - if load_library("json") is - { - error(err) then - println("load lib error:"); - println("--> can't load extension lib. Hence use anubis version"); - _format_json(json) - ok(json_lib) then - _format_json(json_lib, json), -// with start = unow, -// result = _format_json(json_lib, json), -// println(show_duration_string("format_json with extension ",start)); -// result - }. - -public define String - to_JSON_String - ( - String str - ) = - //try to use adl version of json escape string - if load_library("json") is - { - error(err) then - println("load lib error:"); - println("--> can't load extension lib. Hence use anubis version"); - format_json_esc(str) - ok(json_lib) then - to_JSON_String(json_lib, str) - }. - -public define String - format_json - ( - JsonValue json - ) = - to_String(format_json(json)). - - -public define WriteFileResult - write_to_file - ( - String filename, //filename where the JSON will be dump - JsonValue json //JSON to dump - )= - write_to_file(filename, format_json(json)). diff --git a/web/CXM_making_a_web_site.anubis b/web/CXM_making_a_web_site.anubis deleted file mode 100644 index 432f053..0000000 --- a/web/CXM_making_a_web_site.anubis +++ /dev/null @@ -1,5664 +0,0 @@ - - - *Project* Anubis - - *Title* Making interactive Web sites. - - *Copyright* Copyright (c) Alain Prouté 2004-2005. - Copyright (c) Calexium 2007-2017. - Copyright (c) David René 2007-2020. - - - *Authors* Alain Prouté - David René - Jérémy Larrieu - Julien Verneuil - - - *Revised* May 2015 - - - *Overview* - - In this file we propose simple tools for making well structured interactive and secured - web sites. - - - ----------------------------------- Table of Contents --------------------------------- - - * (1) Structure of a web site. - ** (1.1) Three sorts of data. - ** (1.2) How requests are handled. - ** (1.3) What web pages are made of. - ** (1.4) Actions. - ** (1.5) States. - - * (2) Carrying on. - ** (2.1) Describing your web sites. - ** (2.2) Directories on the server's disk. - ** (2.3) Starting your web sites. - - * (3) The HTML interface. - ** (3.1) Types used by the HTML interface. - ** (3.2) ``in form'' versus ``off form''. - ** (3.3) Defining your own style. - ** (3.4) Actioners and forms. - ** (3.5) Local popup. - - --------------------------------------------------------------------------------------- - - -transmit tools/basis.anubis -read tools/printable_tree.anubis -read tools/base64.anubis -read tools/random.anubis -read tools/avlt_dictionaries.anubis -read system/lists.anubis -read system/string.anubis -read system/logger.anubis -transmit CXM_common.anubis -transmit CXM_multihost_http_server.anubis -read web/mime.anubis - -read CXM_cookies.anubis -read CXM_json.anubis -transmit CXM_web_dump.anubis -transmit CXM_web_arg_utils.anubis -transmit CXM_web_session.anubis -transmit CXM_web_action.anubis - -transmit xlib/web/types/web_action_name.anubis -transmit xlib/web/types/making_a_web_site.anubis - -//TODO move anywhere - - -define List(Word8) -/** Test for HTML entity which must be encoded - * and return the encoded entity if needed - */ - get_entity - ( - Word8 _char, - List(Word8) tail - )= - //test for the ampersand - if _char = '&' then - //test if it's already an encoded string like & < etc. In that case we do nothing - if insensitive_equal(['&','a','m','p',';'], tail, 0) then [_char] - else if insensitive_equal(['&','l','t',';'], tail, 0) then [_char] - else if insensitive_equal(['&','g','t',';'], tail, 0) then [_char] - else if insensitive_equal(['&','q','u','o','t',';'], tail, 0) then [_char] - else - [';','p','m','a','&'] - //test for '<' etc. - else if _char = '<' then [';','t','l','&'] - else if _char = '>' then [';','t','g','&'] - else if _char = '\"' then [';','t','o','u','q','&'] - else [_char] -. - -define String - _HTML_encode_entities - ( - List(Word8) source, - List(Word8) current - )= - if source is - { - [] then implode(reverse(current)), - [c . t] then - _HTML_encode_entities(t, get_entity(c, t) + current) - } -. - -public define String - encode_HTML_entities - ( - String source - )= - _HTML_encode_entities(explode(source), []) -. - -//public define String -// encode_HTML_entities -// ( -// String source -// )= -//. - -//read CXM_html_tooltip.anubis - - * (1) Structure of a web site. - - First of all we need to explain what a web site should be made of. Ideally, the - visitor (also called the 'client') should see the web site working as any other - interactive computer software. So, it should be clear that a 'session' (i.e. a visit - to the web site, including the consultation of several pages) is some kind of - conversation between the visitor and the web site, and that the web site should - maintain a 'current state' of this conversation. At each new request (click) from the - visitor, this state must be updated. This whole conversation is called a 'session' and - should not be confused with a single request. - - - - ** (1.1) Three sorts of data. - - All the data needed for putting a web site at work may be dispatched into three - categories: - - 1. Constant data (data that never change). These data may be hard coded into the - Anubis source files of the web site. - - 2. Permanent data (data which always exist independantly of the users connected to - the web site). These data are normally recorded into data bases. - - 3. Session data (data which depend on a particular visitor and which exist only - during the time he visits the web site). These data are stored into so-called - 'states'. - - - It is important to determine which data belongs to which category. This is part of your - design decisions. - - - - ** (1.2) How requests are handled. - - We want to separate the following two functionalities (which are used at each request - (click) during a single session): - - - computing the new state from the previous state and from the client request, and - updating the data base, - - - computing the page to be sent to the client from the new current state and from - the informations in the data base. - - - The next picture shows the structure we have in mind: - - - request +---------+ HTML page (with state name in cookie) - .-------------------| client |<--------------. - | .-----------------| | | - | | session +---------+ | - | | in cookie | - | | | client side - ............................................................................ - | | | server side - | | | - | | .-------------------. | - | | | previous session | | - V V V | | - +---------------+ +---------------+ +--------------+ - | compute state | | server's disk | | compute page | - +---------------+ +---------------+ +--------------+ - ^ | | ^ ^ ^ ^ ^ - | | | | | | | | - | | `--------------------+--------------------' | | - | | new state | | | - read | `------------------------+--------------------' | - write | new state name | - update V | - +-----------+ | - | data base |--------------------------------------------' - +-----------+ read only - - - When the client begins a session, there is no previous state. In this case, a default - 'initial state' is used instead. - - The data base may be updated by 'compute state' box, but should not be update by the - 'compute page' box. The 'compute page' box should be allowed only to read the data - base. - - In this file, all the above stuff is defined, except the 'compute state' and 'compute - page' boxes. You just have to provide the function for computing a new state (compute - state) and the function for computing the page (compute page) from the new state. You - don't have to worry about state names, saving and retrieving states and the like. - - - - - - ** (1.3) What web pages are made of. - - What the client can see in his browser's window may be called a 'page'. Within a page, - we have several sorts of components: - - - 'local' components, i.e. all components which do not open a connection, like - texts, images, etc... possibly using JavaScript programmation, - - - 'actioners', which, when clicked upon, open a connection with our web site; they - may appear as links or buttons, etc... - - - 'foreign links', which when clicked upon, open a connection with another web site - (or ours eventually). - - Of course, what an actioner does is just ask our web site to perform an action. To that - end, the actioner essentially sends the name of the action to be performed. However, it - may be necessary to provide additional informations which may be seen as 'operands' of - the action. In order to attach operands to an action, HTML provides the notion of - 'form'. Indeed, a form contains essentially a set of input fields into which the client - may put values for the required operands of the action, and a submit button, which is - the actioner itself. Notice that a single form may contain several submit buttons, - which simply means that there are several distincts actions taking the same set of - operands. - - Restrictions must be put on the use of all theses gadgets. Indeed, for example, - putting a form within another form is officially meaningless in HTML, and the client's - browser may be seriously disturbed by this. In this file, we propose an interface to - the HTML language, which forbids such meaningless things, simply by imposing a strict - typing of HTML concepts. - - Each web site may be accessible through two communication channels: - - - a non secured channel (HTTP), - - a secured channel (HTTPS). - - Nevertheless, the whole thing should be considered as a single web site. For example, - you may have a secured page, obtained through HTTPS, containing public images obtained - through HTTP. An actioner in a non secured page may open a secured connection, and - conversely. - - Summarizing, a web page is made of local elements, foreign links and actioners. - Actioners receive operands from forms, and they also choose to communicate through the - non secured or through the secured channel. - - - - +-------------------+ - | page | - | | +---------------+ - | +--------------+ | | next page | - | | form | | | (non secured) | - | | +----------+ | | HTTP | | - | | | actioner |---------------------------->| | - | | +----------+ | | +---------------+ - | | | | - | | +----------+ | | +---------------+ - | | | actioner |---------------------------->| next page | - | | +----------+ | | HTTPS | (secured) | - | | | | | | - | +--------------+ | | | - | | +---------------+ - | | - +-------------------+ - - - Notice that actioners need no be necessarily put into forms. In that case, they work as - ordinary links, but they still may receive operands as we shall see. - - - - - ** (1.4) Actions. - - The client opens a new connection with our web site whenever he clicks on an - actioner. The result is that a request is sent, essentially made of a list of 'web - arguments'. Each web argument is a pair (name,value). One of these web arguments, the - 'action' web argument (whose name is "a"), determines the action to be performed. The - other web arguments (not including "s", used to identify the state) are the operands - for this action. - - Hence, the 'compute state' box in the picture above, splits naturally into as many - sub-boxes as there are actions. For this reason, we define the following type for - representing actions (where '$State' is the type representing session informations): - - - - 'http_action's are executed only under HTTP, and 'https_action's are executed only - under HTTPS. 'http_https_action's may be executed under both types of connections. - - Each action has a name, which is used to identify the action. Each action also has a - function 'allow' whose job is to verify that the action is allowed in the current - state, and a function 'do_it' for performing the action. The function 'do_it' receives - a lot of informations: - - - 'HTTP informations': - - the IP address of the client, - - the URI requested by the client (after redirection), - - the list of HTTP headers generated by the client's browser, - - the list of web arguments sent by the client (except "s" and "a"), - - the previous state (or the 'initial' or 'ticket expired' state if no previous - state can be found). - - In most cases, HTTP informations are not used. This is the reason why they are gathered - for simplicity into a unique datum of type 'HTTP_Info'. - - - - - When you define your web site, you must provide the list of all the actions of the - site. When a new state has been computed, a graphical representation of this state - must be sent to the client. To that end, you must provide a function (named below - 'compute_page') of type: - - $State -> HTTP_Answer - - where the type 'HTTP_Answer' (defined below in this file) abstractly represents HTML - pages. - -//public type HTTP_Answer:... - - It should be clear that states and pages are deeply linked together. Indeed, we really - understand the page shown to the client as a representation of the current state of the - conversation between the client and the web site, but also containing informations - taken from the data bases. - - -//public type HTML_Partial_Content:... - - - - - - - - - -public define List(HTTP_header) - make_session_cookie_headers - ( - String website_name, - String session_name - ) - = - //println("Set-Cookie state_"+website_name+"="+state_name); - [ - http_header("Set-Cookie", "session_"+website_name+"="+session_name) - ] - . - - - - When a request arrives, we need to retrieve the previous state from the server's - disk. We receive the name of that state. If the state is out of date, the state file is - kept 3 days, and then deleted. - - - - -define One - delete_out_of_date_sessions // for all web sites - ( - List((String, List(String) -> One)) directories_and_functions - )= - if directories_and_functions is - { - [ ] then unique, - [h . t] then - since h is (state_directory, function), - function(directory_list(state_directory,"*")); - delete_out_of_date_sessions(t) - } -. - - ** (1.5) States. - - Now, we explain how you can define the type (say 'State') to be used as an instance of - the type parameter '$State'. The following is just a suggestion. - - Each state determines a page (since 'compute_page' computes a page from a - state). However, some components of the state may be independant of the page. It may be - the case for example for the indication of the natural language used by the - client. Hence, a state should be made of (at least) two parts: - - - informations which are the same for all pages, - - informations which are particular to each page. - - For example, you could define: - - type Page: // one alternative per page, with particular informations - login(...), // in the components - main_page(...), - ...etc... - - Now, the type 'State' could be defined as follows: - - type State: - state(Language, // informations valid for all pages - ..., - Page). // informations particular to a page - - However, if you are making a secured web site within which clients should be identified - (by id and password), it may be a good idea to have two sorts of states, one for non - identified clients and one for identified clients. In this case, define the type - 'State' as follows (this is just a suggestion): - - type State: - non_identified(Language), - identified(String id, - Language, - Page). - - When a request arrives, check if the previous state is 'identified(...)' or - 'non_identified(...)', and don't provide access to certain pages to non identified - clients. This is required for security. - - Some more words on security. If your site needs to identify clients, define the - initial state as 'non_identified(...)'. Construct a 'login' page, and check the id and - password of the client. If the id and password are correct, then change the state of - the client to 'identified(...)'. No other action should be able to do that. Now, be - confident that clients cannot forge states. The only information they have is the name - of a state, not the state itself which is never sent over the network, but only stored - on the server's disk. The name of the state is constructed using strong cryptographical - methods (sha1). If everything (since the 'login' page) is performed under HTTPS, even - state names cannot be seen by a third party. So, if the system retrieves a previous - state of the form 'identified(...)', you can be confident that your client is well - identified, and you can send him confidential informations. - - States have a limited life time. It may happen that a client clicks on a button at a - time its state is out of date. In this case, this system considers that the new state - is a special state named 'ticket expired'. You must provide a function producing this - state when you describe your web site. The page corresponding to this state must just - inform the client that he/she waited a too long time before clicking on a button, and - has to restart (a new conversation) from the begining. - - - - * (2) Carrying on. - - ** (2.1) Describing your web sites. - - Before you may start your web site, you must describe it, i.e. produce a datum of the - opaque type 'Web_Site'. - -public type Web_Site:... - - Producing such a datum may be performed by: - - public define Web_Site - make_web_site_description - ( - List(String) common_names, // for example: ["www.our-business.com", - // "192.168.0.1"] - // the second one is just for testing - String site_directory, // where 'public' and other directories are - // located (should NOT end with '/') - String state_directory, - One -> One init, - (HTTP_Info, - List(Web_arg), - Bool is_https) -> $State initial_state, - ($State expired, - Maybe(String), - HTTP_Info, - List(Web_arg), - Bool is_https) -> $State ticket_expired_state, - (Maybe(String), - HTTP_Info, - List(Web_arg), - Bool is_https) -> $State ticket_lost_state, - List(Web_Action($State)) actions, - $State -> HTTP_Answer compute_page, - $State -> List(HTTP_header) additional_headers, - List(HTTP_header) constant_additional_headers, - Int timeout, // seconds (todo: minutes) - Redirections redirections, - String charset, - List(String) journal_extensions, - List(String) journal_headers, - String authorization_secret, - List(MIME) known_mime_types, - (String action_name, - List(Web_arg) args)-> One before_send_file - ). - - - Explanations: - - 'common_names' is the list of names of the site (the name the browser must send as the - value of the 'Host' HTTP header in order to access the site must be in that list). Such - a name generally looks like this: - - www.somewhere.com - - If you are using HTTPS, you also have an 'X.509 SSL server certificate'. The name of - the site must be exactly the same as the name on the certificate (which is precisely - called the 'common name' in the X.509 jargon). If the two names do not match, the site - will still work, but the transaction will not be transparent to the client. His browser - will complain that the name of the certificate does not match the name of the site, and - he will have to accept the certificate manually. - - 'site_directory' is the absolute path to the directory where the files needed by the - site are located. Usually this directory looks like: - - my_anubis/web_sites/www.somewhere.com - - However, this information is not computed from 'common_name', so that you can change - the common name (for example temporarily, for networking reasons) without loosing - access to the files. - - 'ticket_expired_state(expired_state,http_info,lwa,is_https)' must produce the state - whose graphical representation is a page explaining to the user that its 'ticket' (or - 'session information') has expired, and that he/she must close all popup windows and - start a new session. The arguments of the function contain the previous (expired) - state and all current informations concerning the user. This arguments may be useful - for example for producing the expiration message in the language chosen by the user. - You can also (and this may be much smarter) send a 'ticket prolongation page' - (including a new login for example), and resume the same conversation, since you have - all the pertinent informations at hand. In the case the ticket is definitely lost, the - second fonction 'ticket_lost_state' is used. - - Notice that despite the fact that the parameter $State is involved in the arguments of - the above function, the type 'Web_Site' does not depend on this parameter. This allows - to produce lists of web site descriptions, where each description may be constructed - with a different instance of $State. This is required because distinct sites must have - distinct types of session informations. This is made possible by the fact that the - type is obscure, and the constructor replaced by a function which assembles - 'ticket_expired_state', ticket_lost_state', 'actions' and 'compute_page' into a single - entity not depending on $State. You should have a look to the private part of this file - if you want more precisions about this programming technique. - - 'charset' is a string which will determine the character encoding to be used by the - browser. Typically, this string is one of: "UTF-8", "ISO-8859-1", "Windows-1252", - etc... - - 'before_send_file' is a function which is executed just before the HTTP server sends a - file. It gets an action name and the web arguments received with the request for that - file. Notice that this action name and these web arguments may be put into a - 'private_download' element, and will come back to the server at the time of the - download. - - - - ** (2.2) Directories on the server's disk. - - The description of your site contains the name of the directory within which the - required files are located. This may be for example: - - my_anubis/web_sites/www.our-business.com/ - - This is called the 'site directory' (for the given site). Within the site directory, - the following directories are created by this program: - - states - public - journal - private_download - upload_temporary - - The directory 'states' is used for storing states (session informations). Out of date - states are automatically removed after some time. - - The tree rooted at 'public' contains files that the server is allowed to send to the - clients. For security reasons, the server never sends a file which is not within the - tree whose root is this 'public' directory (except for the 'private download' mecanism; - see 'web/multihost_http_server.anubis'). Also, the MIME type (see 'web/mime.anubis') - must have been recognized before the file may be sent. - - The directory 'journal' contains the jounal files. The roles of the remaining - directories 'private_download' and 'upload_temporary' is explained in - 'multihost_http_server.anubis', where you will also find further informations on - 'public' and 'journal'. - - - ** (2.3) Web servers parameters. - - The web servers have several parameters useful for administration. They are described - as follows: - - public type WebServersParameters: - wsparms(Var(Bool) shutdown_required, - - ** (2.4) Starting your web sites. - - When you have described all your web sites (you may want to have several web sites, and - they are distinguished by their 'common name'), you may start them all together using - 'start_web_sites' below. This function returns a result of the following type: - -public type Start_Web_Sites_Result: - cannot_bind_to_port(Word32), - cannot_bind_to_port(Word32,Word32), - ok(Server http_server, - Server https_server). - - Indeed, it may happen that the system cannot bind (begin to listen) to one of the two - ports (or to both). The main reason is that another server is already listening on that - port. Another reason may be that 'anbexec' has not been correctly installed, i.e. that - the 's' bit has not been set for 'user' and 'group' (there is not such problem under - Windows). Also notice that the Linux kernel may need a rather long time (up to several - minutes) before liberating a listening port. Now, if the system can bind to the two - ports, the pair of the two servers is returned. Two tools are useful for manipulating - servers: - - shutdown of type Server -> One - is_down of type Server -> Bool - - They are defined in 'predefined.anubis' (together with the type 'Server'). - - -public define Start_Web_Sites_Result - start_web_sites - ( - Word32 ip_address, // the IP address shared by the web sites - Word32 http_port, // usually: 80 - Word32 https_port, // usually: 443 - String ssl_certificate_common_name, - List(Web_Site) web_sites, // web sites to be started - (One) -> Bool shutdown_required - ). - - 'ip_address' is the IP address on which the two servers listen. If you put 0, the - servers listen on all the IP addresses of the machine. This may be useful if the - machine has several network interfaces. - - 'ssl_certificate_common_name' is the common name of the SSL certificate that 'anbexec' - loads when it starts. One instance of 'anbexec' cannot handle more than one SSL server - certificate. This is due to a problem of conception of SSL itself. See the book 'SSL - and TLS' by Eric Rescorla (at Addison Wesley) for more explanations. - - Notice that the number of servers is always 2, regardless of the number of web sites - you are starting. - - The dynamic variable 'shutdown_required' may be used to control the shutdown of the two - servers from within the web site (typically the administration part). The servers will - shutdown as soon as this variable contains 'true'. So you must provide a variable - containing 'false' otherwise your servers will not run. You may also use the primitive - 'must_restart' (see 'predefined.anubis') to control the restarting of your servers. - - * (3) The HTML interface. - - We propose an interface to dynamic HTML. Dynamic HTML includes HTML, and a combination - of CSS (Cascading Style Sheet) and JavaScript techniques for making HTML elements more - reactive and attractive on the client side. - - - ** (3.1) Types used by the HTML interface. - - For easy reference, we gather below the definitions of all the types used by the HTML - interface, and we comment them immediately. - - //public type HTML_Off_Form:... - - -public define Printable_tree [HTML_Id x . Printable_tree y] = str_pt(x.id, y). -public define Printable_tree [HtmlClass x . Printable_tree y] = str_pt(x.class, y). -public define Printable_tree [WebArgName x . Printable_tree y] = str_pt(x.name, y). -public define Printable_tree [WebArgValue x . Printable_tree y] = str_pt(x.value, y). -public define Printable_tree [InitialValue x . Printable_tree y] = str_pt(x.value, y). - -public define CoreAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false"). - - -public define InputAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false"). - - - -public define Text_Option - tooltip(String s) = title(s). - - A list of 'Text_Option' must be given with each text you want to put in your page. - -public define CoreAttrs - tooltip(String s) = title(s). -public define InputAttrs - tooltip(String s) = title(s). - - -public type I18n: - lang (String), - dir (Reading_Way). - - - A list of 'DIV_Option' must be given with each DIV you want to put in your page. - -public define String - event_name - ( - HtmlEvents e - ) = - if e is - { - onafterprint then "onafterprint", //HTML5 Script to be run after the document is printed - onbeforeprint then "onbeforeprint", //HTML5 Script to be run before the document is printed - onbeforeunload then "onbeforeunload", //HTML5 Script to be run when the document is about to be unloaded - onerror then "onerror", //HTML5 Script to be run when an error occurs - onhashchange then "onhashchange", //HTML5 Script to be run when there has been changes to the anchor part of the a URL - onload then "onload", // Fires after the page is finished loading - onmessage then "onmessage", //HTML5 Script to be run when the message is triggered - onoffline then "onoffline", //HTML5 Script to be run when the browser starts to work offline - ononline then "ononline", //HTML5 Script to be run when the browser starts to work online - onpagehide then "onpagehide", //HTML5 Script to be run when a user navigates away from a page - onpageshow then "onpageshow", //HTML5 Script to be run when a user navigates to a page - onpopstate then "onpopstate", //HTML5 Script to be run when the window's history changes - onresize then "onresize", //HTML5 Fires when the browser window is resized - onstorage then "onstorage", //HTML5 Script to be run when a Web Storage area is updated - onunload then "onunload", // Fires once a page has unloaded (or the browser window has been closed) - // Form element events - onblur then "onblur", // Fires the moment that the element loses focus - onchange then "onchange", // Fires the moment when the value of the element is changed - oncontextmenu then "oncontextmenu", //HTML5 Script to be run when a context menu is triggered - onfocus then "onfocus", // Fires the moment when the element gets focus - oninput then "oninput", //HTML5 Script to be run when an element gets user input - oninvalid then "oninvalid", //HTML5 Script to be run when an element is invalid - onreset then "onreset", // Fires when the Reset button in a form is clicked - onsearch then "onsearch", // Fires when the user writes something in a search field (for ) - onselect then "onselect", // Fires after some text has been selected in an element - onsubmit then "onsubmit", // Fires when a form is submitted - // Keyboard events (Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.) - onkeydown then "onkeydown", // Fires when a user is pressing a key - onkeypress then "onkeypress", // Fires when a user presses a key - onkeyup then "onkeyup", // Fires when a user releases a key - // Mouse events (Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.) - onclick then "onclick", // Fires on a mouse click on the element - ondblclick then "ondblclick", // Fires on a mouse double-click on the element - onmousedown then "onmousedown", // Fires when a mouse button is pressed down on an element - onmousemove then "onmousemove", // Fires when the mouse pointer is moving while it is over an element - onmouseout then "onmouseout", // Fires when the mouse pointer moves out of an element - onmouseover then "onmouseover", // Fires when the mouse pointer moves over an element - onmouseup then "onmouseup", // Fires when a mouse button is released over an element - onwheel then "onwheel", //HTML5 Fires when the mouse wheel rolls up or down over an element - //Drag Events - ondrag then "ondrag", //HMTL5 Script to be run when an element is dragged - ondragend then "ondragend", //HTML5 Script to be run at the end of a drag operation - ondragenter then "ondragenter", //HTML5 Script to be run when an element has been dragged to a valid drop target - ondragleave then "ondragleave", //HTML5 Script to be run when an element leaves a valid drop target - ondragover then "ondragover", //HTML5 Script to be run when an element is being dragged over a valid drop target - ondragstart then "ondragstart", //HTML5 Script to be run at the start of a drag operation - ondrop then "ondrop", //HTML5 Script to be run when dragged element is being dropped - onscroll then "onscroll", //HTML5 Script to be run when an element's scrollbar is being scrolled - //Clipboard Events - oncopy then "oncopy", //HTML5 Fires when the user copies the content of an element - oncut then "oncut", //HTML5 Fires when the user cuts the content of an element - onpaste then "onpaste", //HTML5 Fires when the user pastes some content in an element - //Media Events - onabort then "onabort", //HTML5 Script to be run on abort - oncanplay then "oncanplay", //HTML5 Script to be run when a file is ready to start playing (when it has buffered enough to begin) - oncanplaythrough then "oncanplaythrough", //HTML5 Script to be run when a file can be played all the way to the end without pausing for buffering - oncuechange then "oncuechange", //HTML5 Script to be run when the cue changes in a element - ondurationchange then "ondurationchange", //HTML5 Script to be run when the length of the media changes - onemptied then "onemptied", //HTML5 Script to be run when something bad happens and the file is suddenly unavailable (like unexpectedly disconnects) - onended then "onended", //HTML5 Script to be run when the media has reach the end (a useful event for messages like "thanks for listening") - onerror then "onerror", //HTML5 Script to be run when an error occurs when the file is being loaded - onloadeddata then "onloadeddata", //HTML5 Script to be run when media data is loaded - onloadedmetadata then "onloadedmetadata", //HTML5 Script to be run when meta data (like dimensions and duration) are loaded - onloadstart then "onloadstart", //HTML5 Script to be run just as the file begins to load before anything is actually loaded - onpause then "onpause", //HTML5 Script to be run when the media is paused either by the user or programmatically - onplay then "onplay", //HTML5 Script to be run when the media is ready to start playing - onplaying then "onplaying", //HTML5 Script to be run when the media actually has started playing - onprogress then "onprogress", //HTML5 Script to be run when the browser is in the process of getting the media data - onratechange then "onratechange", //HTML5 Script to be run each time the playback rate changes (like when a user switches to a slow motion or fast forward mode) - onseeked then "onseeked", //HTML5 Script to be run when the seeking attribute is set to false indicating that seeking has ended - onseeking then "onseeking", //HTML5 Script to be run when the seeking attribute is set to true indicating that seeking is active - onstalled then "onstalled", //HTML5 Script to be run when the browser is unable to fetch the media data for whatever reason - onsuspend then "onsuspend", //HTML5 Script to be run when fetching the media data is stopped before it is completely loaded for whatever reason - ontimeupdate then "ontimeupdate", //HTML5 Script to be run when the playing position has changed (like when the user fast forwards to a different point in the media) - onvolumechange then "onvolumechange", //HTML5 Script to be run each time the volume is changed which (includes setting the volume to "mute") - onwaiting then "onwaiting", //HTML5 Script to be run when the media has paused but is expected to resume (like when the media pauses to buffer more data) - //Misc Events - onshow then "onshow", //HTML5 Fires when a element is shown as a context menu - ontoggle then "ontoggle" - }. - - -public define Table_Option nude = border(0,0,0,rgb(0,0,0)). - - - A list of 'Table_Option' must be given with each table. - - - - - - - A list of 'Cell_Option' must be given with each cell and each row in a table. Options - given with a row apply to all the cells in the row, but are superseded by options given - with cells, which apply only to the cell they are given with. - - - - - - The parameter $T is later instantiated either to 'HTML_In_Form' or to 'HTML_Off_Form', - depending on where you put your table (within a form or not within a form). For your - convenience, we define the following particular case: - -public define HTML_Cell($T) - cell - ( - $T content - )= - cell([],content) -. - -public define HTML_Cell($T) - cell - ( - Cell_Option option, - $T content - ) = - cell([option],content) -. - -public define HTML_Header_Cell($T) - header_cell - ( - $T content - ) = - header_cell([],content). - - - - - Same remark as for 'HTML_Cell($T)'. We define several convenience functions: - -public define HTML_Row($T) - row - ( - List(HTML_Cell($T)) cells - )= - row([],cells). - -public define HTML_Row($T) - row - ( - HTML_Cell($T) cell - )= - row([],[cell]). - -public define HTML_Row($T) - row - ( - List(Cell_Option) options, - HTML_Cell($T) cell - )= - row(options,[cell]). - -public define HTML_Row($T) - row - ( - Cell_Option option, - HTML_Cell($T) cell - )= - row([option],[cell]). - -public define HTML_Header_Row($T) - header_row - ( - List(HTML_Header_Cell($T)) cells - ) = - header_row([],cells). - -public define HTML_Header_Row($T) - header_row - ( - HTML_Header_Cell($T) cell - ) = - header_row([],[cell]). - - - -public define Actioner_Aspect - immediate_selector - ( - List(CoreAttrs) core_attrs, - WebArgName name, - Int size, - List((List(CoreAttrs),WebArgValue,String)) choices - )= - immediate_selector(core_attrs, name, size, choices, failure, "") - . - -public define Actioner_Aspect - immediate_selector - ( - List(CoreAttrs) core_attrs, - WebArgName name, - Int size, - List((List(CoreAttrs),WebArgValue,String)) choices, - Maybe(InitialValue) selected - )= - immediate_selector(core_attrs, name, size, choices, selected, "") - . - - -public define Actioner_Aspect - link - ( - List(Text_Option) options, - String text - )= - link(options, text, failure). - -public define Actioner_Aspect - link - ( - String text - ) = - link([], text, failure). - - -public define Actioner_Aspect - link - ( - List(Text_Option) options, - Int i - ) = - link(options, to_decimal(i), failure). - -public define Actioner_Aspect - link - ( - Int i - ) = - link([], i). - -public define Actioner_Aspect - button - ( - String url_img - ) = - button(url_img,url_img). - - Actioners are explained in details below. - - - - - -public define String - to_String - ( - CSS_File_Media css_file_media - )= - if css_file_media is - { - screen then "screen", - tty then "tty", - tv then "tv", - projection then "projection", - handheld then "handheld", - print then "print", - braille then "braille", - aural then "aural", - all then "all" - }. - - -//public type HTML_Meta:... - - - -public define HTML_Head_Tag - js_script - ( - String script_content - )= - js_inline(script("text/javascript", script_content)) -. - /* Label with help */ - - -public define HTML_tooltip - html_tooltip - ( - String keyword, - Int width - )= - html_tooltip("", keyword, width). - -public define HTML_tooltip - html_tooltip - ( - String title, - String keyword - )= - html_tooltip(title, keyword, 0). - - - -public define HTML_Help - tooltip - ( - HTML_tooltip h_tooltip - )= - tooltip(h_tooltip, left) -. - - - - /* It contains - * - a List of HTML_Head_Tag representing necessaries head tags for the content. ex: jquery js files, js script, css specific styles, ... - * - a HTML_Off_Form representing the HTML code for the part of the page we want to display - */ -//public type HTML_In_Form:... - - - -public define List(HTML_Head_Tag) - to_HTML_Head_Tag - ( - List(CSS_File) css_file_list - )= - map((CSS_File css_f) |-> css(css_f), css_file_list). - -public define List(HTML_Head_Tag) - to_HTML_Head_Tag - ( - List(JS_File) js_file_list - )= - map((JS_File js_f) |-> js(js_f), js_file_list). - - - - 'HTML_In_Form' defines all the elements you may put within a form. We define a - convenience function: - - -public define HTML_In_Form text_input(HTML_Label label, HTML_Id id, WebArgName name, InitialValue init, Int width) = text_input([], label, id, name, init, width). - -public define HTML_In_Form literal(Printable_tree t) = literal_pt(t). - -public define HTML_In_Form image(String url) = image([], url, url). - -public define HTML_In_Form image(String url, Int width, Int height) = image([], url, url, width, height). - -public define HTML_In_Form - foreign_link - ( - Int tsize, - String url, - String name - ) = - foreign_link([size(tsize)],url,name). - -public define HTML_In_Form -/* Older call with String as action instead of WEB_Action_Name. - * This function exists only for compatibility with older project. - * Please condiser to use above function instead - */ - actioner - ( - Actioner_Connection conn, - Actioner_Target targ, - Actioner_Aspect asp, - String action, - List((String,String)) extra_ops, - List(Actioner_Local_Action) local_actions - )= - actioner(conn,targ,asp,action_name(action),extra_ops,local_actions) -. - -public define HTML_In_Form - actioner - ( - Actioner_Connection conn, - Actioner_Target targ, - Actioner_Aspect asp, - WEB_Action_Name action, - List((String,String)) extra_ops - )= - actioner(conn,targ,asp,action,extra_ops,[]) -. - -public define HTML_In_Form -/* Older call with String as action instead of WEB_Action_Name. - * This function exists only for compatibility with older project. - * Please condiser to use above function instead - */ - actioner - ( - Actioner_Connection conn, - Actioner_Target targ, - Actioner_Aspect asp, - String action, - List((String,String)) extra_ops - )= - actioner(conn,targ,asp,action_name(action),extra_ops,[]) -. - -public define HTML_In_Form - actioner - ( - Actioner_Connection conn, - Actioner_Target targ, - Actioner_Aspect asp, - )= - actioner(conn, targ, asp, action_name(""), [], []). - - -public define HTML_In_Form - text_area - ( - WebArgName name, - InitialValue init, - Int width, - Int height - ) = - text_area([], no_label, html_Id(""), name,init,width,height). - -public define HTML_In_Form - text_area - ( - List(TextAreaOption) options, - WebArgName name, - InitialValue init, - Int width, - Int height - ) = - text_area(options, no_label, html_Id(""), name,init,width,height). - -public define HTML_In_Form - table - ( - List(HTML_Row(HTML_In_Form)) rows - ) = - table([],empty,rows,empty). - -public define HTML_In_Form - table - ( - List(Table_Option) options, - List(HTML_Row(HTML_In_Form)) rows - ) = - table(options,empty,rows,empty). - -public define HTML_In_Form - table - ( - HTML_Header_Row(HTML_In_Form) h_row, - List(HTML_Row(HTML_In_Form)) rows - ) = - table([],h_row,rows,empty). - -public define HTML_In_Form - table - ( - List(Table_Option) options, - HTML_Header_Row(HTML_In_Form) h_row, - List(HTML_Row(HTML_In_Form)) rows - ) = - table(options,h_row,rows,empty). - -public define HTML_In_Form - private_download - ( - String abs_path, - String name, - String extra_ext - ) = - private_download(abs_path,name,extra_ext,failure). - -public define HTML_In_Form - private_download - ( - String abs_path, - String name, - String extra_ext, - String action_name, - List((String,String)) args - ) = - private_download(abs_path,name,extra_ext,success((action_name,args))). - - - -public define HTML_In_Form - text - ( - List(CoreAttrs) l, - Int i - ) = - text(l, to_decimal(i)). - -public define HTML_In_Form - text - ( - String s - )= - text([],s) -. - -public define HTML_In_Form - text - ( - Int i - ) = - text([], i) -. - -public define HTML_In_Form - div - ( - HTML_In_Form element - )= - div([], [element]) -. - -public define HTML_In_Form - div - ( - List(CoreAttrs) attrs, - HTML_In_Form element - )= - div(attrs, [element]) -. - -public define HTML_In_Form - span - ( - String s - )= - span([],s) -. - -public define HTML_In_Form - span - ( - Int i - ) = - span([], to_decimal(i)) -. - -public define HTML_In_Form - radio_button (List(CoreAttrs) options, HTML_Label label, WebArgName n, WebArgValue value, Bool checked) - = radio_button (options, label, html_Id(n.name), n, value, checked). - -public define HTML_In_Form - radio_button_r (List(CoreAttrs) options, HTML_Label label, WebArgName n, WebArgValue value, Bool checked) - = radio_button_r (options, label, html_Id(n.name), n, value, checked). - -public define HTML_In_Form - check_box (List(CoreAttrs) options, HTML_Label label, WebArgName n, Bool checked) - = check_box (options, label, html_Id(n.name), n, checked). - -public define HTML_In_Form - check_box_r (List(CoreAttrs) options, HTML_Label label, WebArgName n, Bool checked) - = check_box_r (options, label, html_Id(n.name), n, checked). - -public define HTML_In_Form - file_upload (WebArgName n, Int width) - = file_upload([], no_label, html_Id(n.name), n, width). - -public define HTML_In_Form - hidden (WebArgName name, WebArgValue value) - = - hidden(html_Id(""), name, value). - -public type Input_Type: -button, -checkbox, -color, -date, -datetime_local, -email, -file, -hidden, -image, -month, -number, -password, -radio, -range, -reset, -search, -submit, -tel, -text, -time, -url, -week -. - - -//public type HTML_Body:... - - - - 'HTML_Off_Form' defines all the elements you may put outside any form. - -public define HTML_Off_Form text(List(CoreAttrs) attrs, Int i) = text(attrs, to_decimal(i)). -public define HTML_Off_Form text(CoreAttrs attr, Int i) = text([attr], i). -public define HTML_Off_Form text(Int i) = text([], i). -public define HTML_Off_Form text(String s) = text([], s). -public define HTML_Off_Form text(CoreAttrs attr, String s) = text([attr], s). - -public define HTML_Off_Form a(A_href _href) = a([], _href, _self, []). -public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href) = a(attrs, _href, _self, []). -public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href, HTML_Off_Form content) = a(attrs, _href, _self, [content]). -public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href, List(HTML_Off_Form) content) = a(attrs, _href, _self, content). -public define HTML_Off_Form a(A_href _href, HTML_Off_Form content) = a([], _href, _self, [content]). -public define HTML_Off_Form a(A_href _href, List(HTML_Off_Form) content) = a([], _href, _self, content). -public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href, A_target _target, HTML_Off_Form content) = a(attrs, _href, _target, [content]). -public define HTML_Off_Form a(CoreAttrs attr, A_href _href, A_target _target, HTML_Off_Form content) = a([attr], _href, _target, [content]). -public define HTML_Off_Form a(A_href _href, A_target _target, HTML_Off_Form content) = a([], _href, _target, [content]). -public define HTML_Off_Form a(A_href _href, A_target _target, List(HTML_Off_Form) content) = a([], _href, _target, content). -public define HTML_Off_Form a(CoreAttrs attr, A_href _href, A_target _target, List(HTML_Off_Form) content) = a([attr], _href, _target, content). - - //
-public define HTML_Off_Form article(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("article", attrs, content). -public define HTML_Off_Form article(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("article", attrs, [content]). -public define HTML_Off_Form article(List(HTML_Off_Form) content) = html_tag("article", [], content). -public define HTML_Off_Form article(HTML_Off_Form content) = html_tag("article", [], [content]). - - //