PAGE HTML
PAGE HTML
  **module** lang=html
    notations locales
      *collect macros_, javascript
        notation pour fonctions js de html
          ADD_RES ::=
            try
              {a1} = document.getElementById("{a1}").value
              catch
                {a1} = ''
            res = res + "<br>" + '"{a1}" : "'+ {a1} + '",'
            res_2 = res_2 + '"{a1}" : "'+ {a1}+ '",'
            {L}
    MACROS
      *standard texte html
        NUMBERING ON
        *exec
          grand titre pour les onglets
            TITLE_ALL_PAGES = "APPLICATIONS IN PROLOG"
        *base64 ON
      *import notation for files
      notation pour html locales
        INFO_TA ::=
          {a1}
            <textarea name="{a1}" id="{a1}" rows={a3} cols={a4}>{a2}</textarea>
              {L}
        INFO_T ::=
          {a1}
            INPUT {a1}, text, {a2_}
              {L}
        INPUT ::=
          <input type="{a2}" name="{a1}" id="{a1}" value= {a3_}>
            {L}
        ::=
          GREEN
            {a0}
              {L}
      MON_TEXTE
        TITLE
          ETUDE DES APPLICATIONS PROLOG
        HEADER
          page de garde
            BR 3
              BR
              BR
                CENTER
                  XXLARGE
                    BOLD
                      PROLOG APPLICATIONS IN 1995
              BR
                BOLD
                  2 avril 2022
                  *exec
                    r = 'C:\\ANACONDA\\Library'
                      if r not in sys.path and os.path.exists (r) :
                        sys.path.append (r)
                    r = 'C:\\ANACONDA\\sip'
                      if r not in sys.path and os.path.exists (r) :
                        sys.path.append (r)
                    print ('----------------------------------------- importing librairies and date')
                  *exec
                    try
                      import datetime
                        from datetime import date
                        N_DATE = datetime.now().strftime("%d %m %Y at %H:%M")
                      import codecs
                      except
                        N_DATE = "20 April 2022"
                  {} {N_DATE}
              BR 3
        STYLE
          STYLES_2
        NAV
          COLUMNS_2
            NAV_SOMMAIRE
        TEXT
          GOSUB
    ATTENTION
      il y a toujours un temps de retard
        il faut faire tourner le programme python de restructaration
        puis
          générer le html
  TEXTE
    auxiliaires python
      GOSUB
        fichier
    trucs init
      chargement de la BD en mémoire
        {*}
          {dict_base}
        chargement ok
    HTM_FILE census_form
      HTML
        HEAD
          <meta charset="UTF-8">
          STYLE
            STYLE_BASE
              STYLE_TREES
              STYLE_TABLE
            STYLE_SHEET_1
              STYLE_HEADERS_2
                STYLE_NAV_2
            STYLE_DROPDOWN
            button {
              border:1px
              width: 8px;
              background-color: AliceBlue;
              font-size: 8px
              border-radius: 4px;
          SCRIPT
            var tgl = True
            HIDE_ABLE_START
        BODY
          BOLD
            CENTER
              XLARGE
                GREEN
                  FORM FOR PROLOG APPLICATION CENSUS 2022
                    notation
                      TEXTAREA ::=
                        <textarea id="{a1}" name="{a1}" rows="{a2}" cols="{a3}">
                          {L}
                          </textarea>
          SCRIPT
            def valide ()
              *exec
                list_of_infos = [
                  'description', 'name', 'year'
                    'purpose'
                      'domain'
                  'predicates'
                    'lines'
                      'development_effort'
                  'references'
                    'today'
                      'use'
                  'predicates', 'lines'
                  'maintenance_effort', 'development_effort'
                  'prolog', 'platform', 'other_languages'
                  'contact', 'address', 'email', 'telephone'
              *for info in list_of_infos
                var {info}
              var res, res_2
              res = ""
              res_2 = ""
              *for info in list_of_infos
                ADD_RES {info}
                try
                  {info} = document.getElementById("{info}").value
                  catch
                    {info} = ''
                res = res + "<br>" + '"{info}" : "'+ {info} + '",'
                res_2 = res_2 + '"{info}" : "'+ {info}+ '",'
              res = '{<br>' + res.substring (0, res.length -1) + '<br>}'
                res_2 = '{' + res_2.slice (0, -1) + '}'
              @@"afficheur" = res
              res_2
            def clear_html ()
              @@"afficheur" = ""
            def send_census ()
              var res
              var dest = "lgouzenes.net"+ "@gm" + "ail." + "com"
                var dest = "lgouzenes"+ "@k" + "m2-conseil.fr; r.kowalsk" + "i@i" + "mperial.a" + "c.uk"
                console.log (dest)
              prepare data
                res = valide ()
                subject = "prolog%20applications%20census%202022"
                subject = subject + "%20:%20" + document.getElementById("name").value.replace (' ', '%20')
                mal_= "ma" + "ilt" + "o:" + dest + "?subject=" + subject + "&body=" + res
                  console.log (mal_)
              send the text
                win = window.open(mal_,'mailer')
                  if win && win.open &&!win.closed
                    win.close()
          DIV style="background:rgb(220, 220, 220)"
            COTECOTE
              CELL1
                DIV style="background:white"
                  BLUE
                    BOLD
                      CENTER
                        APPLICATION
                    CELL1
                      CENTER
                        Information about the application
                      INFO_T name, some_name
                        Name of application - no special chars
                      INFO_TA domain, teaching education banking etc , 2, 40
                      INFO_TA purpose, what it is supposed to do, 3, 80
                      INFO_TA description, some hints on how it works, 10, 80
                      INFO_TA references, some references, 10, 80
                      INFO_TA use, Personal use/ in-House use / Free/public domain/ Licensed/ Sold product ... and/or more information, 1, 80
                      BOLD
                        CENTER
                          DATES
                      CENTER
                        CELL1
                          CENTER
                            year the application was developped, date of today
                            INFO_T year, 1900
                            INFO_T today, 2022
                      BOLD
                        CENTER
                          COMPLEXITY
                      CENTER
                        CELL1
                            INFO_T predicates, number
                              INFO_T lines, number
                                (give approximate numbers)
                            INFO_T development_effort,number
                            INFO_T maintenance_effort , number
                              GREEN
                                (in men-year)
                            INFO_T prolog, prolog used
                              INFO_T platform, windows etc
                                INFO_T other_languages, java sql etc
                      BOLD
                        CENTER
                          DEVELOPMENT INFO
                      CENTER
                        CELL1
                            INFO_T country, name
                              INFO_T organisation, name public / private
                            INFO_TA developpers, some names, 3, 50
                      BOLD
                        CENTER
                          CONTACT
                      CENTER
                        CELL1
                            INFO_T contact, name
                              (name)
                            INFO_T address , address
                              INFO_T email , email
                                INFO_T telephone, +xxxxxxxxxxx
              CELL1
                  CENTER
                    BOUTON VALID, valide ()
                      BOUTON SEND, send_census ()
                    BOUTON CLEAR OUTPUT, clear_html ()
                      BOUTON CLEAR_INPUT
                  BOLD
                    GREEN
                        The VALID button will show in the RESULT frame was will be sent, but does nothing else.
                        The SEND button will open a "mailto:" window
                            Before hitting SEND, please check with VALID that your anwer is correctly treated
                            If the MAIL window does not open, then just copy/paste the content of the RESULT frame and
                                send it to Laurent (lgouzenes.net at gmail com )
                                with subject=prolog applications census 2022
                  CELL1
                    BOLD
                      RESULT
                    RED
                      CELL1
                        ID afficheur
                          no result
                    BOUTON_GO TOP PAGE OF PROLOG, https://www.km2-conseil.fr//PROLOG/PROLOG.htm
                    BOUTON_GO CENSUS 1995 OF APPLICATIONS, https://www.km2-conseil.fr//PROLOG/DOCS/APPLICATIONS/VIEILLES_APPLICATIONS/PROCESSING%20OLD%20APPLICATIONS%20IN%20PROLOG.htm
    menus et options
      DESCRIPTION
        Introduction
          This page contains a structured presentation of a survey made in 1995.
          The data was collected as presented below.
          This page is generated automatically from this database
          This page is part of a larger work developped by the prolog community :
            BOUTON_GO TOP PAGE OF PROLOG, https://www.km2-conseil.fr//PROLOG/PROLOG.htm
        Methodology
          COLUMNS_2
            CELL1
              BOLD
                The 1995 Survey
              Entries may be made either by the original authors or (by agreement) those in
              contact with them who have access to the information asked for (which includes
              the size of program and time taken). Entries are not limited to commercial
              programs - shareware and non-distributed and privately used programs are
              perfectly acceptable, but we are not interested in programming exercises. The
              results of research projects may be submitted if they have actually been used
              for their designed end.
              BR
              An entry only takes a few minutes, so why not do it right away? Pass this file
              on to your friends and get them to enter too!
              BR
              As it was in 1995 :
                  Send entries to:
                    Al Roth, PO Box 137, Blackpool, Lancashire, FY2 0XY, U.K.
                    Email: alroth@cix.compulink.co.uk
                    Fax: +44 253 53811 Telephone: +44 253 58081.
                    (Floppy disks for PC or Mac in text form are also welcome,
                      and paper entries may also be sent).
                  Queries may also be addressed to the people who conceived the project:
                    Chris Moss (cdsm@doc.ic.ac.uk)
                    Leon Sterling (leon@alpha.ces.cwru.edu)
                  Sponsored by: ALP-UK, Dept. Computing, Imperial College, London SW7 2BZ
                    Email: alpuk@doc.ic.ac.uk
              The form is available here :
                database 1995 FORM
              BR
              BOLD1 Today :
                  send to :
              BOLD
                new form
                  census_form.htm
            CELL1
      Here we need some buttons and filters to access more easily data
          BOUTON HIDE ALL
            BOUTON SHOW ALL
        BY DOMAIN
          BOUTON FINANCE
            BOUTON SPEECH
              etc
    presentation par domaines
      DOMAINS
        BOLD
          Projects are grouped by keywords which are present in the various fields of the database.
            A project can appear in several domains.
          *loop domain in domains
            *exec
              domain_info= domains.get (domain, {})
              filters = domain_info.get ('results', False)
            ---------------------------------------
              RED
                  {domain}
                    {*}
                      ( {len (filters)} projects )
                        ---------------------------------------
            DETAILS
              COLUMNS_3
                *if filters
                  *loop info in filters
                    *exec
                      project, program, key, ref = info
                      project_low = project.lower ()
                    {*}
                      BLUE
                        <a href="#{project_low}">{project}</a>
                          ({key},{ref})
                      {program}
    presentation par ages
      APPLICATIONS BY YEAR
        BOLD1 Warning
          some errors may occur because of automation.
        BR
        first sort by date and buckets
          *exec
            dict_years = {}
              for p , p_dict in dict_base.iteritems ()
                year = p_dict.get ('year_deployed', 1900)
                L = dict_years.get (year, False)
                  if not L
                    dict_years[year] = L = []
                L.append (p)
          *loop year in sorted (dict_years. keys ())
            BOLD
              {*}
                {year if year != 1900 else 'year unknown'}
                  : {len (dict_years[year]) } projects
            DETAILS
              COLUMNS_3
                *for project in dict_years[year]
                  *exec
                    d_proj = dict_base [project]
                      purpose =d_proj ['Purpose']
                    project_low = project.lower ()
                  {*}
                    BLUE
                      <a href="#{project_low}">{project}</a>
                    {purpose}
    affichage
      BR
        PROJECTS
          suite
            notation
              SHOW_D ::=
                *vars
                  {show_d_p}
                    show_d_p = True
                      echo a1, infos.get (a1, '')
                      if infos.get (a1, '') = ''
                        show_d_p = False
                *if show_d_p == True
                  BOLD
                    {a1} :
                    {*}
                      {infos.get ('{a1}', '')}
                  {L}
                nothing {show_d_p}
            BOLD
              You can click on the ∑ symbol to go back to the summary
            Detailed list of all projects
              DETAILS
                  *loop project in dict_base
                    *exec
                      infos = dict_base [project]
                        project_low = project.lower()
                    BOLD
                      BLUE
                          <a href="#SOMMAIRE">∑</a>
                            {*}
                              <span id="{project_low}"></span>
                                project : {project}
                      Project
                        {project}
                          SHOW_D Date deployed
                            Dates
                          SHOW_D year_deployed
                            Dates
                          SHOW_D Dated
                            Dates
                          SHOW_D References
                            Dates
                          SHOW_D Domain
                            Description
                          SHOW_D Purpose
                            Description
                          SHOW_D Description
                            Description
                          SHOW_D Developers
                            People
                          SHOW_D Developed by
                            People
                          SHOW_D Organization
                            People
                          SHOW_D Country
                            People
                          SHOW_D Contact
                            People
                          SHOW_D Address
                            People
                          SHOW_D Telephone
                            People
                          SHOW_D Email
                            People
                          SHOW_D Prolog system
                            Resources
                          SHOW_D Platform
                            Resources
                          SHOW_D Other languages
                            Resources
                          SHOW_D Lines
                            Resources
                          SHOW_D Predicates
                            Resources
                          SHOW_D Development effort
                            Resources
                          SHOW_D Use
                            Dates
                          SHOW_D Current Status
                            Dates
                          SHOW_D Users
                            Dates
                          SHOW_D Type of Use
                            Description
                          SHOW_D No. of Users
                            Description
  auxiliaires python
    *exec
      *import NOTATIONS DE BASE
      import os
        import os.path
          import json
        import codecs
    *exec
      start ...
        notation
          x_show ::=
            print (u"++++++++++++++++ {a0}")
              {L}
          some_error ::=
            # some error : {a0}
              print ( {a1_} )
            pass
            {L}
        les fonctions de base
          # fonctions simples
            def dict_from_file (file)
              DESCRIPTION
                lit un fichier json
                ENTREES
                  file :
                    nom d'un fichier .json
                SORTIES
                  d :
                    dictionnaire ou liste
                ATTENTION
                  il faut vérifier de lire .json, .JSON, .Json
              # tests unitaire
                manuel
              echo 'dict_from_file', file
              if file existe
                try
                  with codecs.open (file, 'r', encoding = 'utf-8') as fs
                    d = json.load (fs)
                      echo 'lecture ok'
                        d
                  except
                    some_error 'erreur de lecture de ', file
                    {}
                else
                  some_error 'fichier n existe pas', file
                  pre = file [:-4]
                    for suf in ['json', 'JSON', 'Json']
                      nfile = pre + suf
                        if nfile existe
                          try
                            echo nfile
                            with open (nfile, 'r', encoding ='utf-8') as fs
                              d = json.load (fs)
                                d
                            except
                              continue
                  {}
            def file_to_dict (fname)
              dict_from_file (fname)
            def dict_to_file (d, file)
              DESCRIPTION
                écrit un dictionnaire dans un fichier au format json
                  et pretty
                ENTREES
                  file : nom d'un fichier .json
                  d :
                    dictionnaire ou liste
                SORTIES
              # tests unitaire
                manuel
              echo file
              if isinstance (d, str) and isinstance (file, dict)
                d, file = file, d
              try
                with codecs.open (file, 'w', encoding = 'utf-8') as fs
                  json.dump(d, fs, indent = 4)
                    d
                except
                  some_error 'fichier n existe pas', file
                  False
            def file_dict_update (file, nom, val)
              DESCRIPTION
                file contient un dictionnaire
                met à jour le chap nom avec la valeur val
              try
                dico = dict_from_file (file)
                dico [nom] = val
                dict_to_file (dico, file)
                True
                except
                  False
            def file_dict_value (file, nom)
              DESCRIPTION
                file contient un dictionnaire
                récupère la valeur du champ associé
              try
                dico = dict_from_file (file)
                val = dico.get (nom, False)
                val
                except
                  False
            def dict_file_value (file, nom)
              DESCRIPTION
                file contient un dictionnaire
                récupère la valeur du champ associé
              file_dict_value (file, nom)
            def file_dict_delete (file, nom)
              DESCRIPTION
                file contient un dictionnaire
                suppprime le champ nom
              try
                dico = dict_from_file (file)
                if nom in dico
                  del dico [nom]
                dict_to_file (dico, file)
                True
                except
                  False
            P_8 : remplacement caractères spéciaux
              global liste_chars_escape
                liste_chars_escape = [ ('é', '&eacute;'), ('è', '&egrave;'), ('à','&agrave;'), ('ù','&ugrave;'), ('ê','&ecirc;'), ('â', '&acirc;'), ('û','&ucirc;'), ('î','&icirc;'), ('ô','&ocirc;'), ('ë', '&euml;'), ('ï', '&iuml;'), ('ö','&ouml;'), ('ü','&uuml;'), ('ç','&ccedil;') ]
                liste_chars_escape = [ (u'é', '&eacute;'), (u'è', '&egrave;'), (u'à','&agrave;'), (u'ù','&ugrave;'), (u'ê','&ecirc;'), (u'â', '&acirc;'), (u'û','&ucirc;'), (u'î','&icirc;'), (u'ô','&ocirc;'), (u'ë', '&euml;'), (u'ï', '&iuml;'), (u'ö','&ouml;'), (u'ü','&uuml;'), (u'ç','&ccedil;') ]
              def P_8 (u)
                # DESCRIPTION
                  pour passer d'une chaine str en une chaine escaped
                global liste_chars_escape
                if isinstance (u, str) or isinstance (u,unicode)
                  for a, b in liste_chars_escape
                    if a in u
                      u = u.replace (a, b)
                u
              def P_8_rev (u)
                # DESCRIPTION
                  permet de passer d'une chaine escaped en unicode
                global liste_chars_escape
                if isinstance (u, str) or isinstance (u,unicode)
                  if '&' in u
                    for a, b in liste_chars_escape
                      if b in u
                        u = u.replace (b, a)
                u
        notation
          ' F= ' ::= {a_1} = DIR_BASE J+ "{a1_}"
    *exec
      global DIR_BASE
        DIR_BASE = "D:\\LG SAVOIRS\\PROLOG\\DOCS\\APPLICATIONS\\VIEILLES APPLICATIONS"
      global dict_base
        print ('=========================== préparation du fichier html====================')
        dict_base = dict ()
      global domains
        domains = {}
      récupération des projets
        data_f2 = os.path.join (DIR_BASE, 'data_d2.json')
          data_f2 = os.path.join (DIR_BASE, 'data_base_low.json')
          echo dict_base
          echo data_f2
    *exec
      charge le fichier des applications
        if not os.path.exists (data_f2)
          print (' pas de data_f2')
          else
            print ('lecture ...')
              data_f2 = data_f2.replace ('\\', '/')
                echo data_f2
            essai de lecture ligne à ligne
              with codecs.open (data_f2, 'r', encoding = 'utf-8') as f_in
                print ('open ok')
                for line in f_in.readline ()
                  if not line
                    break
                  print ('line = ', line)
                print ('ok <<')
            dict_base = dict_from_file ( data_f2)
      récupération des domaines
        domain_f F= domains.json
          domains = dict_from_file (domain_f)
            echo domains
    *exec
      controle du chargement
        try
          pass
            echo dict_base
            echo 'dict_base loaded'
              echo len (dict_base)
          except
            print ('******************* error in dict_base')