Secciones de la página

img. tol


Declaraciones


Constantes


Funciones


Time oriented language


Árbol de ficheros

Funciones

Set ImgGetSet()

Text ImgNormalize()

Text ImgGetSrc()

Text ImgGetAlt()

Text ImgGetTit()

Text Img2Htm()

Text Img2Div()

Text ImgMap()

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









img.tol de con-Q.tv

Image functions.

Declaraciones

Constantes

  • Text ImgTag
    Tag inicial para imagenes.

Funciones

  • Set ImgGetSet(Text htmCod)
    Retorna el conjunto de imagenes de una pieza de codigo Html.
  • Text ImgNormalize(Text imgCod)
    Retorna el codigo Html de una imagen normalizado.
  • Text ImgGetSrc(Text imgCod)
    Retorna de un codigo Html de una imagen la url de la imagen.
  • Text ImgGetAlt(Text imgCod)
    Retorna de un codigo Html de una imagen el texto alt de la imagen.
  • Text ImgGetTit(Text imgCod)
    Retorna de un codigo Html de una imagen el texto title de la imagen.
  • Text Img2Htm(Text imgSrc, Text imgAlt, Text imgTit, Text imgCla, Text imgDef)
    Retorna el codigo Html de una imagen con sus atributos completos rellenando aquellos que faltan.
  • Text Img2Div(Text imgSrc, Text imgAlt, Text imgTit, Text imgLnk, Text imgLst, Text imgCla, Text imgDef)
    Retorna el codigo Html de una imagen con sus atributos completos rellenando aquellos que faltan y todo dentro de una estructura Html div.
  • Text ImgMap(Set ctrPdb, Text txtPat, Text namCla, Text txtDef)
    Retorna el codigo Html de un mapa o indice de imagenes extraidas de un conjunto de post en Html.

Constantes

Text ImgTag

//////////////////////////////////////////////////////////////////////////////
Text ImgTag = "<img ";
//////////////////////////////////////////////////////////////////////////////
PutDescription("Tag inicial para imagenes.", ImgTag);
//////////////////////////////////////////////////////////////////////////////

Funciones

Set ImgGetSet()

//////////////////////////////////////////////////////////////////////////////
Set ImgGetSet(Text htmCod)
//////////////////////////////////////////////////////////////////////////////
{
  Text imgTxt = Compact(TxtInside2TagPlus(htmCod, ImgTag, ">"));
  If(imgTxt == "", Empty,
  {
    Text imgRep = Replace(imgTxt, "><", ">"+Char(7)+"<");
    Tokenizer(imgRep, Char(7))
  })
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el conjunto de imagenes de una pieza de codigo Html.",
ImgGetSet);
//////////////////////////////////////////////////////////////////////////////

Text ImgNormalize()

//////////////////////////////////////////////////////////////////////////////
Text ImgNormalize(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{
  Text imgCmp = Compact(imgCod);
  ReplaceTable(imgCmp,
  [[
    [["= ",     "="]],
    [[" =",     "="]],
    [[".'",     "'"]], // Elimina los puntos finales
    [[Char(34), "'"]]
  ]])
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el codigo Html de una imagen normalizado.",
ImgNormalize);
//////////////////////////////////////////////////////////////////////////////

Text ImgGetSrc()

//////////////////////////////////////////////////////////////////////////////
Text ImgGetSrc(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{ TxtBetween2Tag(ImgNormalize(imgCod), "src='", "'", TRUE) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna de un codigo Html de una imagen la url de la imagen.",
ImgGetSrc);
//////////////////////////////////////////////////////////////////////////////

Text ImgGetAlt()

//////////////////////////////////////////////////////////////////////////////
Text ImgGetAlt(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{ TxtBetween2Tag(ImgNormalize(imgCod), "alt='", "'", TRUE) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna de un codigo Html de una imagen el texto alt de la imagen.",
ImgGetAlt);
//////////////////////////////////////////////////////////////////////////////

Text ImgGetTit()

//////////////////////////////////////////////////////////////////////////////
Text ImgGetTit(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{ TxtBetween2Tag(ImgNormalize(imgCod), "title='", "'", TRUE) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna de un codigo Html de una imagen el texto title de la imagen.",
ImgGetTit);
//////////////////////////////////////////////////////////////////////////////

Text Img2Htm()

//////////////////////////////////////////////////////////////////////////////
Text Img2Htm(Text imgSrc, // Image path
             Text imgAlt, // Alternate text, mandatory
             Text imgTit, // Image title
             Text imgCla, // Image class
             Text imgDef) // Para cuando no hay textos
//////////////////////////////////////////////////////////////////////////////
{
  Text htmSrc =   " src="+Q(imgSrc);

  Text htmCla = " class="+Q(imgCla);

  Text htmAlt = If(imgAlt!="", " alt="+Q(imgAlt),     // Hay alt
                If(imgTit!="", " alt="+Q(imgTit),     // Sin alt pero si title
                               " alt="+Q(imgDef)));   // Sin nada

  Text htmTit = If(imgTit!="", " title="+Q(imgTit),   // Hay title
                If(imgAlt!="", " title="+Q(imgAlt),   // Sin title pero si alt
                               " title="+Q(imgDef))); // Sin nada

  Text htmImg = "\n  <img" + htmSrc + 
                "\n    "   + htmCla +
                "\n      " + htmAlt + 
                "\n    "   + htmTit + " />";

  htmImg
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el codigo Html de una imagen con sus atributos completos rellenando
aquellos que faltan.",
Img2Htm);
//////////////////////////////////////////////////////////////////////////////

Text Img2Div()

//////////////////////////////////////////////////////////////////////////////
Text Img2Div(Text imgSrc, // Image path
             Text imgAlt, // Alternate text, mandatory
             Text imgTit, // Image title
             Text imgLnk, // Main link
             Text imgLst, // List of links
             Text imgCla, // Image class
             Text imgDef) // Para cuando no hay textos
//////////////////////////////////////////////////////////////////////////////
{
  Text htmImg = Img2Htm(imgSrc, imgAlt, imgTit, imgCla, imgDef);
  
  Text htmTxt = Case
  (
    And(imgAlt != "", imgTit == ""),             imgAlt,
    And(imgAlt == "", imgTit != ""),             imgTit,
    And(imgAlt == "", imgTit == ""),             imgDef,
        imgAlt == imgTit,                        imgAlt,
        TRUE,                        imgTit+": "+imgAlt
  )+". ";
             
  Text htmDes = "<p>"+htmTxt+imgLst+"</p>";

  "\n<div class="+Q(imgCla)+">" +
  "\n  "    + imgLnk + htmImg + "</a>" +
  "\n  "    + htmDes +
  "\n</div><div style="+Q("clear:both")+"></div>\n"
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el codigo Html de una imagen con sus atributos completos rellenando
aquellos que faltan y todo dentro de una estructura Html div.",
Img2Div);
//////////////////////////////////////////////////////////////////////////////

Text ImgMap()

//////////////////////////////////////////////////////////////////////////////
Text ImgMap(Set  ctrPdb, // Set of post from a post database
            Text txtPat, // Text pattern for seleccion in alts and title
            Text namCla, // Name for image class
            Text txtDef) // Para cuando no hay textos
//////////////////////////////////////////////////////////////////////////////
{
  Set  imgPdb = EvalSet(ctrPdb, Set(Set objPst)
  {// Si se crean imágenes dinámicas no las ve, sería recursivo en este post
    Set imgSel = ImgGetSet(objPst->pstHtm); 

    EvalSet(imgSel, Set(Text imgCod)
    {
      Text imgSrc = ImgGetSrc(imgCod);
      Text imgAlt = ImgGetAlt(imgCod);
      Text imgTit = ImgGetTit(imgCod);
      Text imgLnk = PhtLinkPost(objPst);
     
      // Text WriteLn(imgSrc+"\n"+imgAlt+"\n"+imgTit+"\n"+imgLnk+"\n");
      SetOfText(imgSrc, imgAlt, imgTit, imgLnk)
    })
  });

  Set  imgGrp = BinGroup("<<", imgPdb);
  Text lowPat = Compact(ToLower(txtPat));
  Set  imgSel = If(lowPat == "", imgGrp, // Todas las imagenes
  { 
    Select(imgGrp, Real(Set imgSet)
    { Or(TextFind(Compact(ToLower(imgSet[2])), lowPat),    // Busca en alt
         TextFind(Compact(ToLower(imgSet[3])), lowPat)) }) // Busca en title
  });
 
  // Clasifica por el path de la imagen reverse
  Set  imgCla = Classify(imgSel, Real(Set a, Set b) { Compare(b[1], a[1]) }); 

  Set  imgCic = EvalSet (imgCla, Text(Set imgSet)
  {
    Text imgSrc = imgSet[1][1];
    Text imgAlt = imgSet[1][2];

    // Solo si title es diferente al alt     
    Text imgTit = If(imgAlt == imgSet[1][3], "", imgSet[1][3]);

    // El primer link
    Text imgLnk = "<"+TxtBetween2Tag(imgSet[1][4], "<", ">", TRUE)+">";

    Text imgLst = Set2Txt(Traspose(imgSet)[4],
      "En ", ".", ", ", " y ", "", "", "", ""); // Todos los links

    Img2Div(imgSrc, imgAlt, imgTit, imgLnk, imgLst, namCla, txtDef)
  });
  SetSum(imgCic)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el codigo Html de un mapa o indice de imagenes extraidas de un
conjunto de post en Html.",
ImgMap);
//////////////////////////////////////////////////////////////////////////////

Time oriented language

//////////////////////////////////////////////////////////////////////////////
// FILE    : img.tol
// AUTHOR  : http://www.asolver.com
// PURPOSE : Image functions.
//////////////////////////////////////////////////////////////////////////////


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

//////////////////////////////////////////////////////////////////////////////
Text ImgTag = "<img ";
//////////////////////////////////////////////////////////////////////////////
PutDescription("Tag inicial para imagenes.", ImgTag);
//////////////////////////////////////////////////////////////////////////////


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

//////////////////////////////////////////////////////////////////////////////
Set ImgGetSet(Text htmCod)
//////////////////////////////////////////////////////////////////////////////
{
  Text imgTxt = Compact(TxtInside2TagPlus(htmCod, ImgTag, ">"));
  If(imgTxt == "", Empty,
  {
    Text imgRep = Replace(imgTxt, "><", ">"+Char(7)+"<");
    Tokenizer(imgRep, Char(7))
  })
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el conjunto de imagenes de una pieza de codigo Html.",
ImgGetSet);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text ImgNormalize(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{
  Text imgCmp = Compact(imgCod);
  ReplaceTable(imgCmp,
  [[
    [["= ",     "="]],
    [[" =",     "="]],
    [[".'",     "'"]], // Elimina los puntos finales
    [[Char(34), "'"]]
  ]])
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el codigo Html de una imagen normalizado.",
ImgNormalize);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text ImgGetSrc(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{ TxtBetween2Tag(ImgNormalize(imgCod), "src='", "'", TRUE) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna de un codigo Html de una imagen la url de la imagen.",
ImgGetSrc);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text ImgGetAlt(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{ TxtBetween2Tag(ImgNormalize(imgCod), "alt='", "'", TRUE) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna de un codigo Html de una imagen el texto alt de la imagen.",
ImgGetAlt);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text ImgGetTit(Text imgCod)
//////////////////////////////////////////////////////////////////////////////
{ TxtBetween2Tag(ImgNormalize(imgCod), "title='", "'", TRUE) };
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna de un codigo Html de una imagen el texto title de la imagen.",
ImgGetTit);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text Img2Htm(Text imgSrc, // Image path
             Text imgAlt, // Alternate text, mandatory
             Text imgTit, // Image title
             Text imgCla, // Image class
             Text imgDef) // Para cuando no hay textos
//////////////////////////////////////////////////////////////////////////////
{
  Text htmSrc =   " src="+Q(imgSrc);

  Text htmCla = " class="+Q(imgCla);

  Text htmAlt = If(imgAlt!="", " alt="+Q(imgAlt),     // Hay alt
                If(imgTit!="", " alt="+Q(imgTit),     // Sin alt pero si title
                               " alt="+Q(imgDef)));   // Sin nada

  Text htmTit = If(imgTit!="", " title="+Q(imgTit),   // Hay title
                If(imgAlt!="", " title="+Q(imgAlt),   // Sin title pero si alt
                               " title="+Q(imgDef))); // Sin nada

  Text htmImg = "\n  <img" + htmSrc + 
                "\n    "   + htmCla +
                "\n      " + htmAlt + 
                "\n    "   + htmTit + " />";

  htmImg
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el codigo Html de una imagen con sus atributos completos rellenando
aquellos que faltan.",
Img2Htm);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text Img2Div(Text imgSrc, // Image path
             Text imgAlt, // Alternate text, mandatory
             Text imgTit, // Image title
             Text imgLnk, // Main link
             Text imgLst, // List of links
             Text imgCla, // Image class
             Text imgDef) // Para cuando no hay textos
//////////////////////////////////////////////////////////////////////////////
{
  Text htmImg = Img2Htm(imgSrc, imgAlt, imgTit, imgCla, imgDef);
  
  Text htmTxt = Case
  (
    And(imgAlt != "", imgTit == ""),             imgAlt,
    And(imgAlt == "", imgTit != ""),             imgTit,
    And(imgAlt == "", imgTit == ""),             imgDef,
        imgAlt == imgTit,                        imgAlt,
        TRUE,                        imgTit+": "+imgAlt
  )+". ";
             
  Text htmDes = "<p>"+htmTxt+imgLst+"</p>";

  "\n<div class="+Q(imgCla)+">" +
  "\n  "    + imgLnk + htmImg + "</a>" +
  "\n  "    + htmDes +
  "\n</div><div style="+Q("clear:both")+"></div>\n"
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el codigo Html de una imagen con sus atributos completos rellenando
aquellos que faltan y todo dentro de una estructura Html div.",
Img2Div);
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
Text ImgMap(Set  ctrPdb, // Set of post from a post database
            Text txtPat, // Text pattern for seleccion in alts and title
            Text namCla, // Name for image class
            Text txtDef) // Para cuando no hay textos
//////////////////////////////////////////////////////////////////////////////
{
  Set  imgPdb = EvalSet(ctrPdb, Set(Set objPst)
  {// Si se crean imágenes dinámicas no las ve, sería recursivo en este post
    Set imgSel = ImgGetSet(objPst->pstHtm); 

    EvalSet(imgSel, Set(Text imgCod)
    {
      Text imgSrc = ImgGetSrc(imgCod);
      Text imgAlt = ImgGetAlt(imgCod);
      Text imgTit = ImgGetTit(imgCod);
      Text imgLnk = PhtLinkPost(objPst);
     
      // Text WriteLn(imgSrc+"\n"+imgAlt+"\n"+imgTit+"\n"+imgLnk+"\n");
      SetOfText(imgSrc, imgAlt, imgTit, imgLnk)
    })
  });

  Set  imgGrp = BinGroup("<<", imgPdb);
  Text lowPat = Compact(ToLower(txtPat));
  Set  imgSel = If(lowPat == "", imgGrp, // Todas las imagenes
  { 
    Select(imgGrp, Real(Set imgSet)
    { Or(TextFind(Compact(ToLower(imgSet[2])), lowPat),    // Busca en alt
         TextFind(Compact(ToLower(imgSet[3])), lowPat)) }) // Busca en title
  });
 
  // Clasifica por el path de la imagen reverse
  Set  imgCla = Classify(imgSel, Real(Set a, Set b) { Compare(b[1], a[1]) }); 

  Set  imgCic = EvalSet (imgCla, Text(Set imgSet)
  {
    Text imgSrc = imgSet[1][1];
    Text imgAlt = imgSet[1][2];

    // Solo si title es diferente al alt     
    Text imgTit = If(imgAlt == imgSet[1][3], "", imgSet[1][3]);

    // El primer link
    Text imgLnk = "<"+TxtBetween2Tag(imgSet[1][4], "<", ">", TRUE)+">";

    Text imgLst = Set2Txt(Traspose(imgSet)[4],
      "En ", ".", ", ", " y ", "", "", "", ""); // Todos los links

    Img2Div(imgSrc, imgAlt, imgTit, imgLnk, imgLst, namCla, txtDef)
  });
  SetSum(imgCic)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Retorna el codigo Html de un mapa o indice de imagenes extraidas de un
conjunto de post en Html.",
ImgMap);
//////////////////////////////////////////////////////////////////////////////

Á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