[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdeaddons/konq-plugins/webarchiver
From:       Peter Kelly <pmk () post ! com>
Date:       2003-07-19 6:06:14
[Download RAW message or body]

CVS commit by pmk: 

Fix references in external stylesheets


  M +20 -5     plugin_webarchiver.cpp   1.27
  M +2 -2      plugin_webarchiver.h   1.6


--- kdeaddons/konq-plugins/webarchiver/plugin_webarchiver.cpp  #1.26:1.27
@@ -242,10 +242,11 @@ void PluginWebArchiver::saveArchiveRecur
         } else if
 #endif
-        if ((nodeName == "LINK" && attrName == "HREF") || // Down load stylesheets, \
js-script, .. +        bool css = (nodeName == "LINK" && attrName == "HREF");
+        if (css || // Down load stylesheets, js-script, ..
             ((nodeName == "FRAME" || nodeName == "IFRAME") && attrName == "SRC") ||
             ((nodeName == "IMG" || nodeName == "INPUT" || nodeName == "SCRIPT") && \
                attrName == "SRC") ||
             ((nodeName == "BODY" || nodeName == "TABLE" || nodeName == "TH" || \
                nodeName == "TD") && attrName == "BACKGROUND")) {
            // Some people use carriage return in file names and browsers support \
                that!
-           attrValue = handleLink(baseURL, attrValue.replace(QRegExp("\\s"), ""));
+           attrValue = handleLink(baseURL, attrValue.replace(QRegExp("\\s"), ""), \
css);  }
         /*
@@ -345,5 +346,5 @@ void PluginWebArchiver::saveArchiveRecur
 /* Extract the URL, download it's content and return an unique name for the link */
 
-QString PluginWebArchiver::handleLink(const KURL& _url, const QString& _link)
+QString PluginWebArchiver::handleLink(const KURL& _url, const QString& _link, bool \
_css)  {
   KURL url(getAbsoluteURL(_url, _link));
@@ -373,5 +374,19 @@ QString PluginWebArchiver::handleLink(co
       QFile file(fileName);
       file.open(IO_ReadOnly);
+      if (!_css) {
+        // Write file as-is
       m_tarBall->writeFile(tarFileName, QString::null, QString::null, file.size(), \
file.readAll()); +      }
+      else {
+        // Read file into memory and fix all references
+        QTextStream stream(&file);
+        QString cssText = stream.read();
+        QString cssFixed = analyzeInternalCSS(_url,cssText);
+
+        QByteArray outArr;
+        QTextStream outStream(outArr,IO_WriteOnly);
+        outStream << cssFixed;
+        m_tarBall->writeFile(tarFileName, QString::null, QString::null, \
outArr.size(), outArr); +      }
       file.close();
 

--- kdeaddons/konq-plugins/webarchiver/plugin_webarchiver.h  #1.5:1.6
@@ -49,5 +49,5 @@ class PluginWebArchiver : public KParts:
    void saveArchiveRecursive(const DOM::Node &node, const KURL& baseURL,
                              QTextStream* _textStream, int ident);
-   QString handleLink(const KURL& _url, const QString & _link);
+   QString handleLink(const KURL& _url, const QString & _link, bool _css = false);
    KURL getAbsoluteURL(const KURL& _url, const QString& _link);
    QString getUniqueFileName(const QString& fileName);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic