Secciones de la página

pdb. tol


Declaraciones


Constantes


Funciones


Time oriented language


Árbol de ficheros

Funciones

Set PdbRead()

Set PdbFirstN()

Set PdbYearSet()

Tol

Artículos del sitio

Presentación de Tol

Todos los programas

Simuladores visuales

Sitios que me gustan

Por categorías

Algoritmia

Búsqueda y ordenación

Computación fisiológica

Editorial y edición

Gráficos de datos

Herramientas y utilidades

Hipertexto

Informática forense

Lectura óptica de datos

Metaprogramación

No determinista

Ofimática

Recursión e iteración

Reglas y restricciones

Series y estadística









pdb.tol de con-Q.tv

Posts database functions.

Declaraciones

Constantes

  • Text PdbSep
    Post separator inside the agendas.

Funciones

  • Set PdbRead(Text inpDir)
    Reads and returns a post database as a set of structures.
  • Set PdbFirstN(Set inpSet, Real maxNum, Code funSel)
    Returns the maxNum recents posts selected using the function funSel.
  • Set PdbYearSet(Text inpDir)
    Returns a set with all the years numbers, as texts, that have published posts in the agenda directory inpDir.

Constantes

Text PdbSep

//////////////////////////////////////////////////////////////////////////////
Text PdbSep = Repeat("_",78);
//////////////////////////////////////////////////////////////////////////////
PutDescription("Post separator inside the agendas.", PdbSep);
//////////////////////////////////////////////////////////////////////////////

Funciones

Set PdbRead()

//////////////////////////////////////////////////////////////////////////////
Set PdbRead(Text inpDir)
//////////////////////////////////////////////////////////////////////////////
{
  Real err(Text msg) { Text WriteLn("\nERROR: "+msg+"\n"); FALSE }; // Function
  
  Text filSep = Char(7);

  Text WriteLn("Reading "+inpDir+"...");
  Text inpAll = DirReadFiles(inpDir, "age", filSep);

  Text inpTxt = Replace(inpAll, PdbSep+"\n",filSep);
  Set  inpSet = Tokenizer(inpTxt,filSep);

  Set  inpTab = EvalSet(inpSet, Set(Text inf)
  {
    // Read
    Text pstSta = Sub(TxtBetween2Tag(inf, "<Pst.Sta>", "\n<Pst.", TRUE) + 
                      "C",1,1); // C por defecto

    Text pstFil = TxtBetween2Tag(inf, "<Pst.Fil>", "\n<Pst.", TRUE);
    Text pstTit = TxtBetween2Tag(inf, "<Pst.Tit>", "\n<Pst.", TRUE);
    Text pstHtm = TxtBetween2Tag(inf, "<Pst.Txt>", "\n<Pst.", FALSE);

    Text pstRes = TxtOutside2Tag(pstHtm,"<!--INI-->","<!--END-->"); // Resumen

    Set  pstCla =
      Txt2Set(TxtBetween2Tag(inf, "<Pst.Cla>", "\n<Pst.",  TRUE), ";") <<
      SetOfText("Post", Sub(pstFil, 1, 4)); // All are post + publication year

    Text pstTxt = TxtOutHtmScr(pstHtm);

    // Camino completo y limpio
    Text pstPth = PhtCleanFilePath("noticia", pstFil, "html");

    // Check
    Set  chkCla = EvalSet(pstCla, Real(Text claNam) // Category class
    { If(claNam <: CatAll, TRUE, err("Class: "+claNam+" file: "+pstFil)) });

    // Store
    Set  pstObj = PdbSt(pstCla,
                        pstSta,
                        pstPth,
                        pstTit,
                        pstHtm,
                        pstRes,
                        pstTxt);
    pstObj
  });

  Set inpSel = Select(inpTab, Real(Set a) { a->pstSta!="A" }); // Not deleted

  // Check
  Real chkDup =
  {
    Set codCla = Classify(inpTab, Real(Set a, Set b)
                 { Compare(a->pstFil, b->pstFil) });
    Set filDup = EvalSet(codCla, Real(Set cla)
    {
      Real crd = Card(cla);
      Text nam = cla[1]->pstFil;
      If(EQ(crd,1), TRUE, err("Name: "+nam+" "+F(crd)+" times"))
    });
    Card(filDup)
  };
  
  Text WriteLn("Status ABCD "+F(Card(inpTab))+" registers");
  Text WriteLn("Status _BCD "+F(Card(inpSel))+" registers");

  Set inpSor = Sort(inpSel, Real(Set a, Set b) // Reverse file order
               { Compare(b->pstFil, a->pstFil) });

  inpSor // Los ficheros van con fecha, los mas modernos primero
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Reads and returns a post database as a set of structures.",
PdbRead);
//////////////////////////////////////////////////////////////////////////////

Set PdbFirstN()

//////////////////////////////////////////////////////////////////////////////
Set PdbFirstN(Set  inpSet, // Post database
              Real maxNum, // Maximum numbers of posts to return
              Code funSel) // Post selection conditions
//////////////////////////////////////////////////////////////////////////////
{
  Set  selFst = Select(inpSet, funSel); // Select all that funSel()
  SetFirstN(selFst, maxNum)             // Fst maxNum or all if there are few
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns the maxNum recents posts selected using the function funSel.",
PdbFirstN);
//////////////////////////////////////////////////////////////////////////////

Set PdbYearSet()

//////////////////////////////////////////////////////////////////////////////
Set PdbYearSet(Text inpDir)
//////////////////////////////////////////////////////////////////////////////
{
  Text WriteLn("Reading "+inpDir+" years...");
  Set  pthSet = DirExtAll(inpDir, "age", FALSE, TRUE);

  Set  yeaSet = EvalSet(pthSet, Text(Text pthFil)
  { TxtBetween2Tag(pthFil, inpDir+"/", ".", TRUE) }); // agenda/2013.encue...

  // Agrupa años iguales y ordena de más reciente a más antiguo
  Set  yeaCla = Classify(yeaSet, Real(Text a, Text b) { Compare(b,a) });
  
  EvalSet(yeaCla, Text(Set claSet) { claSet[1] }) // Uno por clase
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a set with all the years numbers, as texts, that have published
posts in the agenda directory inpDir.",
PdbYearSet);
//////////////////////////////////////////////////////////////////////////////

Time oriented language

//////////////////////////////////////////////////////////////////////////////
// FILE    : pdb.tol
// AUTHOR  : http://www.asolver.com
// PURPOSE : Posts database functions.
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
// CONSTANTS
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
Text PdbSep = Repeat("_",78);
//////////////////////////////////////////////////////////////////////////////
PutDescription("Post separator inside the agendas.", PdbSep);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
Set PdbRead(Text inpDir)
//////////////////////////////////////////////////////////////////////////////
{
  Real err(Text msg) { Text WriteLn("\nERROR: "+msg+"\n"); FALSE }; // Function
  
  Text filSep = Char(7);

  Text WriteLn("Reading "+inpDir+"...");
  Text inpAll = DirReadFiles(inpDir, "age", filSep);

  Text inpTxt = Replace(inpAll, PdbSep+"\n",filSep);
  Set  inpSet = Tokenizer(inpTxt,filSep);

  Set  inpTab = EvalSet(inpSet, Set(Text inf)
  {
    // Read
    Text pstSta = Sub(TxtBetween2Tag(inf, "<Pst.Sta>", "\n<Pst.", TRUE) + 
                      "C",1,1); // C por defecto

    Text pstFil = TxtBetween2Tag(inf, "<Pst.Fil>", "\n<Pst.", TRUE);
    Text pstTit = TxtBetween2Tag(inf, "<Pst.Tit>", "\n<Pst.", TRUE);
    Text pstHtm = TxtBetween2Tag(inf, "<Pst.Txt>", "\n<Pst.", FALSE);

    Text pstRes = TxtOutside2Tag(pstHtm,"<!--INI-->","<!--END-->"); // Resumen

    Set  pstCla =
      Txt2Set(TxtBetween2Tag(inf, "<Pst.Cla>", "\n<Pst.",  TRUE), ";") <<
      SetOfText("Post", Sub(pstFil, 1, 4)); // All are post + publication year

    Text pstTxt = TxtOutHtmScr(pstHtm);

    // Camino completo y limpio
    Text pstPth = PhtCleanFilePath("noticia", pstFil, "html");

    // Check
    Set  chkCla = EvalSet(pstCla, Real(Text claNam) // Category class
    { If(claNam <: CatAll, TRUE, err("Class: "+claNam+" file: "+pstFil)) });

    // Store
    Set  pstObj = PdbSt(pstCla,
                        pstSta,
                        pstPth,
                        pstTit,
                        pstHtm,
                        pstRes,
                        pstTxt);
    pstObj
  });

  Set inpSel = Select(inpTab, Real(Set a) { a->pstSta!="A" }); // Not deleted

  // Check
  Real chkDup =
  {
    Set codCla = Classify(inpTab, Real(Set a, Set b)
                 { Compare(a->pstFil, b->pstFil) });
    Set filDup = EvalSet(codCla, Real(Set cla)
    {
      Real crd = Card(cla);
      Text nam = cla[1]->pstFil;
      If(EQ(crd,1), TRUE, err("Name: "+nam+" "+F(crd)+" times"))
    });
    Card(filDup)
  };
  
  Text WriteLn("Status ABCD "+F(Card(inpTab))+" registers");
  Text WriteLn("Status _BCD "+F(Card(inpSel))+" registers");

  Set inpSor = Sort(inpSel, Real(Set a, Set b) // Reverse file order
               { Compare(b->pstFil, a->pstFil) });

  inpSor // Los ficheros van con fecha, los mas modernos primero
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Reads and returns a post database as a set of structures.",
PdbRead);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Set PdbFirstN(Set  inpSet, // Post database
              Real maxNum, // Maximum numbers of posts to return
              Code funSel) // Post selection conditions
//////////////////////////////////////////////////////////////////////////////
{
  Set  selFst = Select(inpSet, funSel); // Select all that funSel()
  SetFirstN(selFst, maxNum)             // Fst maxNum or all if there are few
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns the maxNum recents posts selected using the function funSel.",
PdbFirstN);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Set PdbYearSet(Text inpDir)
//////////////////////////////////////////////////////////////////////////////
{
  Text WriteLn("Reading "+inpDir+" years...");
  Set  pthSet = DirExtAll(inpDir, "age", FALSE, TRUE);

  Set  yeaSet = EvalSet(pthSet, Text(Text pthFil)
  { TxtBetween2Tag(pthFil, inpDir+"/", ".", TRUE) }); // agenda/2013.encue...

  // Agrupa años iguales y ordena de más reciente a más antiguo
  Set  yeaCla = Classify(yeaSet, Real(Text a, Text b) { Compare(b,a) });
  
  EvalSet(yeaCla, Text(Set claSet) { claSet[1] }) // Uno por clase
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a set with all the years numbers, as texts, that have published
posts in the agenda directory inpDir.",
PdbYearSet);
//////////////////////////////////////////////////////////////////////////////

Árbol de ficheros

con-Q.tv construye las páginas del sitio y newsletter Con-Q.tv

  • make.tol proceso principal de generacion del sitio web y la newsletter
  • tol directorios de código Tol
    • cmm funciones comunes
      • txt.tol funciones de textos
      • set.tol funciones de conjuntos
      • fil.tol funciones de ficheros
      • dir.tol funciones directorios
      • tme.tol funciones del macro-expansor de Tol en Html
      • img.tol funciones de imagenes Html
      • ftp.tol para generar mandatos para hacer Ftp
      • xsm.tol para construir sitemaps en Xml
    • app funciones especificas de aplicacion
      • ads.tol funciones de anuncios de publicidad
      • pdb.tol funciones de manejo de los posts de una agenda
      • pht.tol funciones auxiliares para el Html de los post
    • inc.tol para la inclusión de ficheros Tol
  • agenda directorio destinado a la agenda de post
  • web directorio destinado a las páginas web generadas
    • css directorio para ficheros de estilo
      • common.css fichero de estilo Css para las páginas Html
    • seed directorio para ficheros semilla
      • seed.htm semilla de página Html con Tol embebido
      • lopd.htm texto Lopd para insertar en la newsletter de envío por email
    • src directorio para ficheros con código Javascript
      • common.js funciones Javascript para diferentes redes sociales
    • noticia directorio para páginas de noticias
    • quiosco directorio para páginas Html de categorias
      • asamblea.html ejemplo de página de categoría generada automáticamente
    • sitemap.xml mapa completo del sitio web generado en Xml automáticamente
  • presentacion.html vídeo de presentación de la Newsletter de la Avppm
  • con-q_tv.pdf documento resumen de funciones del programa de la newsletter

2015 asolver.com | Aviso legal | XHTML | Δ Θ Ξ | Creative Commons | Mapa y funciones del sitio

Tol