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

List:       kde-commits
Subject:    branches/KDE/4.4/kdebase/runtime/nepomuk/kioslaves/nepomuk
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2010-05-09 9:36:51
Message-ID: 20100509093651.64D7DAC8B2 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1124532 by trueg:

Backport: do not follow nie:url using Nepomuk::Resource.

 M  +3 -0      kio_nepomuk.cpp  
 M  +29 -8     resourcepagegenerator.cpp  


--- branches/KDE/4.4/kdebase/runtime/nepomuk/kioslaves/nepomuk/kio_nepomuk.cpp #1124531:1124532
@@ -545,6 +545,9 @@
 
 bool Nepomuk::NepomukProtocol::rewriteUrl( const KUrl& url, KUrl& newURL )
 {
+    if ( url.queryItemValue( QLatin1String( "noFollow" ) ) == QLatin1String( "true" ) )
+        return false;
+
     QString filename;
     Nepomuk::Resource res = splitNepomukUrl( url, filename );
 
--- branches/KDE/4.4/kdebase/runtime/nepomuk/kioslaves/nepomuk/resourcepagegenerator.cpp #1124531:1124532
@@ -19,6 +19,7 @@
 */
 
 #include "resourcepagegenerator.h"
+#include "nie.h"
 
 #include <QtCore/QByteArray>
 #include <QtCore/QTextStream>
@@ -78,7 +79,15 @@
 
         return typeStrings.join( ", " );
     }
+
+    QString encodeUrl( const QUrl& u ) {
+        QUrl url( u );
+        if ( url.scheme() == QLatin1String( "nepomuk" ) ) {
+            url.setEncodedQuery( "noFollow=true" );
 }
+        return QString::fromAscii( url.toEncoded() );
+    }
+}
 
 
 Nepomuk::ResourcePageGenerator::ResourcePageGenerator( const Nepomuk::Resource& res )
@@ -197,12 +206,24 @@
                     os << s.object().toString();
             }
             else {
-                Resource resource( s.object().uri() );
-                os << QString( "<a href=\"%1\">%2</a> (%3)" )
-                    .arg( QString::fromAscii( resource.resourceUri().toEncoded() ) )
-                    .arg( resource.genericLabel() )
-                    .arg( typesToHtml( resource.types() ) );
+                //
+                // nie:url is a special case for which we should never use Resource
+                // since Resource does in turn use nie:url to resolve resource URIs.
+                // Thus, we would get back to m_resource.
+                //
+                KUrl uri = s.object().uri();
+                QString label = uri.fileName();
+                if ( s.predicate() != Nepomuk::Vocabulary::NIE::url() ) {
+                    Resource resource( uri );
+                    uri = resource.resourceUri();
+                    label = QString::fromLatin1( "%1 (%2)" )
+                            .arg( resource.genericLabel(),
+                                  typesToHtml( resource.types() ) );
             }
+                os << QString( "<a href=\"%1\">%2</a>" )
+                    .arg( encodeUrl( uri ),
+                          label );
+            }
             os << "</td></tr>";
         }
     }
@@ -218,9 +239,9 @@
             Nepomuk::Types::Property p( s.predicate().uri() );
             os << "<td align=right>"
                << QString( "<a href=\"%1\">%2</a> (%3)" )
-                .arg( QString::fromAscii( s.subject().uri().toEncoded() ) )
-                .arg( resource.genericLabel() )
-                .arg( typesToHtml( resource.types() ) )
+                .arg( encodeUrl( s.subject().uri() ),
+                      resource.genericLabel(),
+                      typesToHtml( resource.types() ) )
                << "</td>"
                << "<td width=16px></td>"
                << "<td><i>" << ( p.label().isEmpty() ? p.name() : p.label() ) << "</i></td></tr>";
[prev in list] [next in list] [prev in thread] [next in thread] 

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