[Kde-imaging] [Bug 128125] Album title from digikam are not converted into html entities

Angelo Naselli anaselli at linux.it
Fri Jun 2 21:32:42 CEST 2006


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=128125         
anaselli linux it changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From anaselli linux it  2006-06-02 21:32 -------
SVN commit 547624 by anaselli:

Added webifyFileName (from html gallery)
and moved png file from old imagesgallery plugin
BUG: 101656
BUG: 128125

 M  +2 -0      Makefile.am  
 M  +39 -20    cdarchiving.cpp  
 M  +2 -0      cdarchiving.h  
 AM            gohome.png  
 AM            up.png  
 AM            valid-html401.png  


--- trunk/extragear/libs/kipi-plugins/cdarchiving/Makefile.am #547623:547624
 @ -25,3 +25,5  @
 kipiimagebrokenpicdir = $(kde_datadir)/kipi/data
 kipiimagebrokenpic_DATA = image_broken.png
 
+kipiHTML401picdir = $(kde_datadir)/kipi
+kipiHTML401pic_DATA = valid-html401.png gohome.png up.png
--- trunk/extragear/libs/kipi-plugins/cdarchiving/cdarchiving.cpp #547623:547624
 @ -38,6 +38,7  @
 #include <qimage.h>
 #include <qtextcodec.h>
 #include <qtimer.h>
+#include <qregexp.h>
 
 // Include files for KDE
 
 @ -530,7 +531,7  @
         KIPI::ImageCollection album = *it;
         kdDebug( 51000 ) << "HTML Interface for Album: " << album.name() << endl;
 
-        m_AlbumTitle      = album.name();
+        m_AlbumTitle      = webifyFileName(album.name());
         m_AlbumComments   = m_interface->hasFeature(KIPI::AlbumsHaveComments) ?
                             album.comment() : QString();
         m_AlbumCollection = m_interface->hasFeature(KIPI::AlbumsHaveCategory) ?
 @ -793,15 +794,15  @
         {
             stream << "<tr>" << endl;
         }
-        
+
         QString   imgName = (*urlIt).fileName();
         QString   imgPath = (*urlIt).path();
         QFileInfo imgInfo(imgPath);
         QImage    imgProp = QImage(imgPath);
 
-        stream << "<td align='center'>\n<a href=\"pages/"  << imgName << ".htm\">";
+        stream << "<td align='center'>\n<a href=\"pages/"  << webifyFileName(imgName) << ".htm\">";
         kdDebug(51000) << "Creating thumbnail for " << imgName << endl;
-            
+
         d = new KIPICDArchivingPlugin::EventData;
         d->action = KIPICDArchivingPlugin::ResizeImages;
         d->starting = true;
 @ -809,13 +810,13  @
         d->fileName = imgName;
         QApplication::sendEvent(m_parent, new QCustomEvent(QEvent::User, d));
         usleep(1000);
-            
+
         int valRet = createThumb(imgName, (*urlIt).directory(),
                                  imgGalleryDir, imageFormat);
-            
+
         if ( valRet != -1 )
         {
-            QString thumbPath("thumbs/" + imgName + extension(imageFormat));
+            QString thumbPath("thumbs/" + webifyFileName(imgName) + extension(imageFormat));
             stream << "<img class=\"photo\" src=\"" << thumbPath
                    << "\" width=\"" << m_imgWidth
                    << "\" "
 @ -1054,26 +1055,26  @
     const QDir pagesDir(imgGalleryDir + QString::fromLatin1("/pages/"));
     const QDir thumbsDir(imgGalleryDir + QString::fromLatin1("/thumbs/"));
     const QString imgName(imgURL.fileName());
-    
+
     // Html pages filenames
 
     const QString pageFilename = pagesDir.path() +
                                  QString::fromLatin1("/") +
-                                 imgName +
+                                 webifyFileName(imgName )+
                                  QString::fromLatin1(".htm");
-    const QString nextPageFilename =  nextImgURL.fileName() +
+    const QString nextPageFilename =  webifyFileName(nextImgURL.fileName()) +
                                       QString::fromLatin1(".htm");
-    const QString prevPageFilename =  prevImgURL.fileName() +
+    const QString prevPageFilename =  webifyFileName(prevImgURL.fileName()) +
                                       QString::fromLatin1(".htm");
 
     // Thumbs filenames
 
     const QString prevThumb = QString::fromLatin1("../thumbs/") +
-                              prevImgURL.fileName() +
+                              webifyFileName(prevImgURL.fileName()) +
                               extension(m_imageFormat);
 
     const QString nextThumb = QString::fromLatin1("../thumbs/") +
-                              nextImgURL.fileName() +
+                              webifyFileName(nextImgURL.fileName()) +
                               extension(m_imageFormat);
 
     QFile file( pageFilename );
 @ -1240,7 +1241,7  @
 
     // Create the thumbnails for the HTML interface.
 
-    const QString ImageNameFormat = imgName + extension(imageFormat);
+    const QString ImageNameFormat = webifyFileName(imgName) + extension(imageFormat);
     const QString thumbDir = imgGalleryDir + QString::fromLatin1("/thumbs/");
     int extent = m_thumbnailsSize;
 
 @ -1580,10 +1581,9  @
    QDir dir(dirname);
    dir.setFilter ( QDir::Dirs | QDir::Files | QDir::NoSymLinks );
 
-   Temp = "<directory name=\""
-          + EscapeSgmlText(QTextCodec::codecForLocale(), dir.dirName(), true, true)
-          + "\" >\n";
-
+      Temp = "<directory name=\""
+            + EscapeSgmlText(QTextCodec::codecForLocale(), dir.dirName(), true, true)
+            + "\" >\n";
    *stream << Temp;
    
    kdDebug( 51000 ) << "Directory: " << dir.dirName().latin1 () << endl;
 @ -1650,12 +1650,17  @
    kdDebug( 51000 ) << "Adding Collection: " << collection.name() << endl;
 
    QString Temp;
+   QString collection_name;
+   if (m_useHTMLInterface)
+    collection_name = webifyFileName(collection.name());
+   else
+    collection_name = collection.name();
 
    Temp = "<directory name=\""
-          + EscapeSgmlText(QTextCodec::codecForLocale(), collection.name(), true, true)
+          + EscapeSgmlText(QTextCodec::codecForLocale(), collection_name, true, true)
           + "\" >\n";
    *stream << Temp;
-   
+
    KURL::List images = collection.images();
 
    for (KURL::List::iterator it = images.begin();
 @ -1853,6 +1858,20  @
     return strReturn;
 }
 
+
+/**
+ * Produce a web-friendly file name 
+ */
+
+QString CDArchiving::webifyFileName(QString fileName) {
+  fileName=fileName.lower();
+  
+  // Remove potentially troublesome chars
+  fileName=fileName.replace(QRegExp("[^-0-9a-zA-Z]+"), "_");
+
+  return fileName;
+}
+
 }  // NameSpace KIPICDArchivingPlugin
 
 #include "cdarchiving.moc"
--- trunk/extragear/libs/kipi-plugins/cdarchiving/cdarchiving.h #547623:547624
 @ -201,6 +201,8  @
 
   void writeSettings(void);
   void readSettings(void);
+
+  QString webifyFileName(QString fileName);
 };
 
 }  // NameSpace KIPICDArchivingPlugin
** trunk/extragear/libs/kipi-plugins/cdarchiving/gohome.png #property svn:mime-type
   + application/octet-stream
** trunk/extragear/libs/kipi-plugins/cdarchiving/up.png #property svn:mime-type
   + application/octet-stream
** trunk/extragear/libs/kipi-plugins/cdarchiving/valid-html401.png #property svn:mime-type
   + application/octet-stream


More information about the Kde-imaging mailing list