Commit 38f03821d486225c92311bf641791792a662e248

Authored by David René
1 parent 8eb51436

intial release of locale editor.

anubis_dev/applications/locale_editor/src/generic_page.anubis 0 → 100644
  1 +
  2 +read web/making_a_web_site.anubis
  3 +read locale_editor_types.anubis
  4 +
  5 +
  6 + ********************************** Left menu *********************************
  7 +
  8 +public define HTML_Off_Form left_menu(ToolBox tb) =
  9 + table([background_color(rgb(200,200,255))],
  10 + [
  11 +
  12 + row(actioner(same,same,
  13 + link("List dictionnaries"),
  14 + "go_list_dic",
  15 + [("toto", "titi")])),
  16 + row(actioner(same,same,
  17 + link("Create dictionnary"),
  18 + "go_create_dic",
  19 + [])),
  20 + row(actioner(same,same,
  21 + link("back main menu"),
  22 + "go_login",
  23 + []))
  24 + ]).
  25 +
  26 +public define HTML_Page generic_page
  27 + (
  28 + ToolBox tb,
  29 + HTML_Off_Form content
  30 + ) =
  31 + if tb is tool_box( l3 ) then
  32 + html_page
  33 + (
  34 + "L3 Editor - Configuration page", // title of web site
  35 + [], // list of 'META' tags (empty for this site)
  36 + body // body of page
  37 + ([background_color(rgb(255,255,255))],
  38 + center(table([border(1,0,0, rgb(0,0,0)),
  39 + percentage_width(100)
  40 + ],
  41 + // content of page
  42 + [
  43 + //top
  44 + row(cell([columns(3),h_center], text([size(24)],"L3 Editor")/*top_part(lang)*/)),
  45 + //ligne de drapeaux pour la localisation
  46 + row(cell([columns(3),h_center,height(22),background_color(rgb(180,200,255))],text([],"Country flags"))),
  47 +
  48 + row([
  49 + cell([left, top, width(150), background_color(rgb(200,200,255))],
  50 + //here construct the left menu in relation of the page
  51 +// if admin_status is
  52 +// {
  53 +// domain_admin then domain_menu(tb), //Affiche le domaine concerné
  54 +// super_admin then super_menu(tb)
  55 +// }
  56 + left_menu(tb),
  57 + ),
  58 + //cell([width(20)],literal(" ")),
  59 + cell([top,height(400),h_center],content) // <-- content is in right main part
  60 + ])
  61 + ])))). //end main table
  62 +
  63 +.
  64 +
  65 + /** this function show the critical error message for user through the HTML page
  66 + */
  67 +public define HTML_Page compute_page_error(ToolBox tb, String errMsg ) =
  68 + generic_page(tb, text([size(20), color(rgb(255,0,0))],errMsg)).
... ...
anubis_dev/applications/locale_editor/src/home_page.anubis 0 → 100644
  1 +
  2 +
  3 +read locale_editor_types.anubis
  4 +read generic_page.anubis
  5 +read locale/L3.anubis
  6 +read tools/basis.anubis
  7 +read system_colors/rgb.anubis
  8 +read utils.anubis
  9 +read locale/L3LanguageInfo.anubis
  10 +read web/common.anubis
  11 +read web/making_a_web_site.anubis
  12 +
  13 +define List(HTML_Row(HTML_Off_Form)) make_list_all_dic
  14 + (
  15 + List(L3Properties) left_dic,
  16 + Int32 n
  17 + ) =
  18 + if left_dic is
  19 + {
  20 + [] then [],
  21 + [dico_prop . t] then
  22 + if dico_prop is l3Properties(dico_name, sha1, default_lang, creat, update) then
  23 +
  24 + //construit la ligne d'info du dictionnaire
  25 + [
  26 + row( [
  27 + cell([left,background_color(rgb(234,234,234))], //cell options
  28 + //actioner pour éditer directement le domaine
  29 + actioner(same,same,
  30 + link([size(12),font("helvetica")],dico_name),
  31 + "do_view_dico",
  32 + [("dico_name",dico_name)])),
  33 +
  34 + cell([left, background_color(rgb(234,234,234))],
  35 + text([size(12), font("helvetica")],default_lang)),
  36 +
  37 + cell([left, background_color(rgb(234,234,234))],
  38 + text([size(12), font("helvetica")],datef_dmy(creat) +" "+dhour_format(creat))),
  39 +
  40 + cell([left, background_color(rgb(234,234,234))],
  41 + text([size(12), font("helvetica")],datef_dmy(update) +" "+dhour_format(update))),
  42 +
  43 + cell([left, background_color(rgb(234,234,234))],
  44 + text([size(12), font("helvetica")],sha1)),
  45 +
  46 +
  47 + ])
  48 + . make_list_all_dic(t, n + 1) //fait la liste des domaines suivants
  49 + ]
  50 + }
  51 + .
  52 +
  53 +//Créer la liste des lignes de tous les dicos à afficher dans la page
  54 +
  55 +define List(HTML_Row(HTML_Off_Form)) list_all_dic =
  56 + //Ligne de titre au-dessus des domaines
  57 + [ row([ cell([left, background_color(rgb(204,204,204))],
  58 + text([size(12), bold,font("helvetica")],"dictionary name")),
  59 +
  60 + cell([left, background_color(rgb(204,204,204))],
  61 + text([size(12), bold, font("helvetica")],"default language")),
  62 +
  63 + cell([left, background_color(rgb(204,204,204))],
  64 + text([size(12), bold, font("helvetica")],"creation date")),
  65 +
  66 + cell([left, background_color(rgb(204,204,204))],
  67 + text([size(12), bold, font("helvetica")],"last update")),
  68 +
  69 + cell([left, background_color(rgb(204,204,204))],
  70 + text([size(12), bold, font("helvetica")],"signature"))
  71 + ]
  72 + )
  73 + ] +
  74 + //Add lines of each dictionnary's properties
  75 + make_list_all_dic(l3_get_all_dic , 0).
  76 +
  77 +define HTML_Off_Form list_dictionnaries
  78 + (
  79 + ToolBox tb,
  80 + String errMsg
  81 + ) =
  82 + if tb is tool_box( l3 ) then
  83 + //createDomainForm +
  84 + table(//les options de la table. Ici le bord et la largeur
  85 + [border(1,0,0, rgb(0,0,0)), percentage_width(100) ],
  86 + // content of page
  87 + [
  88 + //top
  89 + row(cell([columns(5),h_center, height(32)], text([size(18)],"All known dictionnaries"))) ] +
  90 + //fabrique toutes les lignes contenant chaque domaine existant
  91 + list_all_dic +
  92 + [
  93 + //Fomulaire de création
  94 + //row(createDomainForm),
  95 + //ligne contenant le texte d'erreur le cas échéant
  96 + row(cell([columns(5),h_center], text([color(red), size(12)], makeErrorMsg(errMsg))))
  97 + ])
  98 +.
  99 +
  100 +
  101 +
  102 +public define HTML_Page compute_home_page (ToolBox tb, String errMsg ) =
  103 + generic_page(tb, list_dictionnaries(tb, errMsg)).
  104 +
  105 +
  106 + define List(HTML_Row(HTML_Off_Form)) make_list_all_dic
  107 + (
  108 + List(L3Properties) left_dic,
  109 + Int32 n
  110 + ) =
  111 + if left_dic is
  112 + {
  113 + [] then [],
  114 +// [h . t] then make_list_all_domains(t, [ row(cell([columns(3),h_center], text([size(24)],h))) . so_far])
  115 + [dico_prop . t] then
  116 + if dico_prop is l3Properties(dico_name, sha1, default_lang, creat, update) then
  117 +
  118 + //construit la ligne d'info du domaine
  119 + [
  120 + row( [
  121 + cell([left,background_color(rgb(234,234,234))], //cell options
  122 + //actioner pour éditer directement le domaine
  123 + actioner(same,same,
  124 + link([size(12),font("helvetica")],dico_name),
  125 + "do_view_dico",
  126 + [("dico_name",dico_name)])),
  127 +
  128 + cell([left, background_color(rgb(234,234,234))],
  129 + text([size(12), font("helvetica")],default_lang)),
  130 +
  131 + cell([left, background_color(rgb(234,234,234))],
  132 + text([size(12), font("helvetica")],datef_dmy(creat) +" "+dhour_format(creat))),
  133 +
  134 + cell([left, background_color(rgb(234,234,234))],
  135 + text([size(12), font("helvetica")],datef_dmy(update) +" "+dhour_format(update))),
  136 +
  137 + cell([left, background_color(rgb(234,234,234))],
  138 + text([size(12), font("helvetica")],sha1)),
  139 +
  140 +
  141 + ])
  142 + . make_list_all_dic(t, n + 1) //fait la liste des domaines suivants
  143 + ]
  144 + }
  145 + .
  146 +
  147 +define State do_view_dico(List(Web_arg) lwa, State s) =
  148 + if s is state(l, t) then
  149 + if web_arg_value(lwa, "dico_name") is
  150 + {
  151 + not_found then s,
  152 + found(dico_name) then
  153 + with dico_name = dico_name + ".L3.symb",
  154 + if l3_get_properties_of(dico_name) is
  155 + {
  156 + failure then state(l, home("can't find the properties of "+ dico_name)),
  157 + success(prop) then state(l, view_dico(prop, ""))
  158 + }
  159 + }
  160 +.
  161 +
  162 +public define List(Web_Action(State)) home_actions =
  163 + [
  164 + http_action("do_view_dico", allow_all, do_view_dico )
  165 + ].
... ...
anubis_dev/applications/locale_editor/src/locale_editor.anubis 0 → 100644
  1 +
  2 +
  3 + *Project* Locale Editor
  4 +
  5 + *Title* Editor for L3 Lib
  6 +
  7 + *Copyright* Copyright (c) David René 2006.
  8 +
  9 +
  10 + *Author* David RENE
  11 +
  12 + *Status* Beta
  13 +
  14 + *Overview*
  15 +
  16 +read tools/basis.anubis // required for 'make_directory'
  17 +read web/common.anubis // required for type 'Web_arg'
  18 +read web/multihost_http_server.anubis // required for type 'HTTP_Info'
  19 +read web/making_a_web_site.anubis
  20 +read web/mime.anubis // required for list of known MIME types
  21 +
  22 +read locale_editor_types.anubis
  23 +read view_dico_page.anubis
  24 +read home_page.anubis
  25 +
  26 + read locale/L3.anubis
  27 +
  28 + *** Server directory.
  29 +
  30 + A directory for putting files for all web sites. There will be one subdirectory per web
  31 + site.
  32 +
  33 +define String web_sites_directory = my_anubis_directory+"/web_sites".
  34 +
  35 +
  36 +
  37 +
  38 +define HTML_Page compute_page( State s ) =
  39 +
  40 + //we extract the member ticket to get
  41 + if s is state( langue, page) then
  42 + with l3 = langue,
  43 + with tb = tool_box(l3),
  44 + if page is
  45 + {
  46 + home(err_msg) then compute_home_page(tb, err_msg),
  47 + view_dico(dico, err_msg) then compute_view_dico_page(dico, tb, err_msg)
  48 + }
  49 + .
  50 +
  51 +define State initialState (HTTP_Info info) =
  52 + state("en", home("")). // there is ony one possible state for web site 1
  53 +
  54 +
  55 + Making the description of web site 1. In this description, several elements are the
  56 + bare minimum. There is no action at all, no data base, almost nothing. See
  57 + 'web/making_a_web_site.anubis' for the declaration of the function
  58 + 'make_web_site_description'.
  59 +
  60 +define Web_Site setup_page =
  61 + // make the directory for web site 1
  62 + // (subdirectories of it will be created automatically by the HTTP server)
  63 + forget(make_directory(web_sites_directory));
  64 +
  65 + // make a list of all possible 'host names' for web site 1:
  66 + with addresses = (List(String))
  67 + [
  68 + "127.0.0.1",
  69 + "LocaleEditor"
  70 + // add more adresses here
  71 + ],
  72 +
  73 + // now make the description of the web site
  74 + make_web_site_description
  75 + (
  76 + // the list of addresses defined above
  77 + addresses,
  78 +
  79 + // directory for the files of web site 1
  80 + web_sites_directory+"/LocaleEditor",
  81 +
  82 + // initializing function
  83 + (One u) |-> u, // nothing to initialize for web site 1
  84 +
  85 + // the function producing the initial state
  86 + initialState,
  87 + // formerly (HTTP_Info info) |-> state("en", not_logged(login)), // there is ony one possible state for web site 1
  88 +
  89 + // the function for handling expired tickets
  90 + // (tickets are kept on the server's disk and represent states. They are used for
  91 + // passing session informations from pages to pages. See
  92 + // 'web/making_a_web_site.anubis' for detailed explanations.)
  93 + (State expired,
  94 + HTTP_Info info,
  95 + List(Web_arg) lwa,
  96 + Bool is_https) |-> initialState(info), // keep the same state
  97 +
  98 + // the function for handling lost tickets
  99 + (HTTP_Info info,
  100 + List(Web_arg) lwa,
  101 + Bool is_https) |-> initialState(info), // restart with default state
  102 +
  103 + // list of all actions
  104 + home_actions ,//makeActionsLogin, // no action for web site 1
  105 +
  106 + // the function for computing the pages of web site 1 (it is defined above)
  107 + compute_page,
  108 +
  109 + // timeout for tickets (in seconds)
  110 + 3600, // does'nt matter since only one state
  111 +
  112 + // list of redirections (one for each address)
  113 + // (see 'web/common.anubis' for the type 'Redirection')
  114 + map((String address) |-> redirect("/",address,"/site1.awp"), addresses),
  115 +
  116 + // character encoding for web site 1
  117 + "UTF-8",
  118 +
  119 + // list of URI extensions producing a console/journal message
  120 + [
  121 + ".awp", // pages computed by this program
  122 + ".jpg", // images, etc...
  123 + ".gif",
  124 + ".png"
  125 + // add more extensions here (they must be known; see 'web/mime.anubis')
  126 + ],
  127 +
  128 + // list of HTTP headers which are traced in the console/journal messages
  129 + [
  130 + "host",
  131 + "user-agent"
  132 + // add more HTTP headers here
  133 + ],
  134 +
  135 + // secret string (used by 'private download')
  136 + "HUD76GRD56FD7GFDS4RT", // for a real site, please choose another one
  137 + // it must remain secret
  138 +
  139 + // list of known MIME types (taken from 'web/mime.anubis')
  140 + known_mime_types,
  141 +
  142 + // action to be performed before a file is sent
  143 + // (for example, this may be used for counting downloads)
  144 + (String action_name,
  145 + List(Web_arg) lwa) |-> unique // no action at all
  146 + ).
  147 +
  148 +
  149 +
  150 +
  151 + *** Example site 2.
  152 +
  153 + Imagine another web site here...
  154 +
  155 +
  156 +
  157 +
  158 +
  159 + *** Starting all our web sites together.
  160 +
  161 +global define One localeEditor ( List(String) args ) =
  162 + // make the directory for all web sites (if needed)
  163 + forget(make_directory(web_sites_directory));
  164 +
  165 + // create a variable for handling the shutdown of our web sites
  166 + with shutdown_required = var((Bool)false),
  167 +
  168 + // start all web sites
  169 + start_web_sites
  170 + (
  171 + 0, // listen on all IP addresses
  172 + 80, // port for HTTP
  173 + 443, // port for HTTPS
  174 + "www.georges.example.com", // common name of SSL certificate
  175 + [
  176 + setup_page
  177 + // add other web sites here
  178 + ],
  179 + shutdown_required
  180 + ).
  181 +
  182 +
  183 +
... ...
anubis_dev/applications/locale_editor/src/utils.anubis 0 → 100644
  1 +/*
  2 + * Created by SoftArchitect.
  3 + * User: david
  4 + * Date: 01/08/2006
  5 + * Time: 23:18
  6 + *
  7 + * To change this template use Tools | Options | Coding | Edit Standard Headers.
  8 + */
  9 +
  10 +
  11 +public define String makeErrorMsg(String msg) =
  12 + if length(msg) > 0 then
  13 + "Error : " + msg
  14 + else
  15 + "".
  16 +
... ...
anubis_dev/applications/locale_editor/src/view_dico_page.anubis 0 → 100644
  1 +
  2 +read web/making_a_web_site.anubis
  3 +read web/common.anubis
  4 +read locale/L3.anubis
  5 +read locale/L3LanguageInfo.anubis
  6 +read locale_editor_types.anubis
  7 +read generic_page.anubis
  8 +read system_colors/rgb.anubis
  9 +read utils.anubis
  10 +read tools/basis.anubis
  11 +
  12 +define List(HTML_Row(HTML_Off_Form))
  13 + make_list_all_sub_dic
  14 + (
  15 + List(L3LangDicProperty) left_dic,
  16 + Int32 n
  17 + ) =
  18 + if left_dic is
  19 + {
  20 + [] then [],
  21 + [dico_prop . t] then
  22 + if dico_prop is l3LangDicProperty( sha1, lang_code, user_def, creat, update) then
  23 + with lang_info = l3_get_language_info(lang_code),
  24 + //construit la ligne d'info du domaine
  25 + [
  26 + row( [
  27 + cell([left,background_color(rgb(234,234,234))], //cell options
  28 + text([size(12), font("helvetica")], english_name(lang_info))),
  29 +
  30 + cell([left, background_color(rgb(234,234,234))],
  31 + text([size(12), font("helvetica")], self_name(lang_info))),
  32 +
  33 + cell([left, background_color(rgb(234,234,234))],
  34 + text([size(12), font("helvetica")],datef_dmy(creat) +" "+dhour_format(creat))),
  35 +
  36 + cell([left, background_color(rgb(234,234,234))],
  37 + text([size(12), font("helvetica")],datef_dmy(update) +" "+dhour_format(update))),
  38 +
  39 + cell([left, background_color(rgb(234,234,234))],
  40 + text([size(12), font("helvetica")],sha1)),
  41 +
  42 +
  43 + ])
  44 + . make_list_all_sub_dic(t, n + 1) //fait la liste des dicos suivants
  45 + ]
  46 + }
  47 + .
  48 +
  49 +define List(HTML_Row(HTML_Off_Form))
  50 + list_all_sub_dic
  51 + (
  52 + String dic_name
  53 + )=
  54 + //Ligne de titre au-dessus des domaines
  55 + [ row([ cell([left, background_color(rgb(204,204,204))],
  56 + text([size(12), bold,font("helvetica")],"Language")),
  57 +
  58 + cell([left, background_color(rgb(204,204,204))],
  59 + text([size(12), bold, font("helvetica")],"language")),
  60 +
  61 + cell([left, background_color(rgb(204,204,204))],
  62 + text([size(12), bold, font("helvetica")],"creation date")),
  63 +
  64 + cell([left, background_color(rgb(204,204,204))],
  65 + text([size(12), bold, font("helvetica")],"last update")),
  66 +
  67 + cell([left, background_color(rgb(204,204,204))],
  68 + text([size(12), bold, font("helvetica")],"SHA1"))
  69 + ]
  70 + )
  71 + ] +
  72 + //Add lines of each dictionnary's properties
  73 + make_list_all_sub_dic(l3_get_all_sub_dic(dic_name) , 0).
  74 +
  75 +define HTML_Off_Form list_dictionnaries_of
  76 + (
  77 + ToolBox tb,
  78 + L3Properties prop,
  79 + String errMsg
  80 + ) =
  81 + if tb is tool_box( l3 ) then
  82 + if prop is l3Properties(dico_name, sha1, default_lang, creat, update) then
  83 + //createDomainForm +
  84 + table(//les options de la table. Ici le bord et la largeur
  85 + [border(1,0,0, rgb(0,0,0)), percentage_width(100) ],
  86 + // content of page
  87 + [
  88 + //top
  89 + row(cell([columns(5),h_center, height(32)], text([size(18)],"All dictionnaries for " + dico_name ))) ] +
  90 + //fabrique toutes les lignes contenant chaque domaine existant
  91 + list_all_sub_dic(dico_name) +
  92 + [
  93 + //Fomulaire de création
  94 + //row(createDomainForm),
  95 + //ligne contenant le texte d'erreur le cas échéant
  96 + row(cell([h_center], text([color(red), size(12)], makeErrorMsg(errMsg))))
  97 + ])
  98 +.
  99 +
  100 +public define HTML_Page
  101 + compute_view_dico_page
  102 + (
  103 + L3Properties prop,
  104 + ToolBox tb,
  105 + String errMsg ) =
  106 + generic_page(tb, list_dictionnaries_of(tb, prop, errMsg)).
... ...