hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1517829 - in /httpcomponents/project-release-tools/trunk: buildSrc/src/main/groovy/Html.groovy site.gradle
Date Tue, 27 Aug 2013 14:26:18 GMT
Author: olegk
Date: Tue Aug 27 14:26:18 2013
New Revision: 1517829

URL: http://svn.apache.org/r1517829
Log:
Fix site CSS and logo references

Modified:
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Html.groovy
    httpcomponents/project-release-tools/trunk/site.gradle

Modified: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Html.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Html.groovy?rev=1517829&r1=1517828&r2=1517829&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Html.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Html.groovy Tue Aug
27 14:26:18 2013
@@ -71,16 +71,22 @@ class Html {
                     String qName,
                     Attributes atts) throws SAXException {
                 AttributesImpl newatts = null;
-                if (localName.equalsIgnoreCase('a')) {
-                    int idx = atts.getIndex('href')
-                    if (idx != -1) {
-                        newatts = new AttributesImpl(atts)
-                        try {
-                            URI href = new URI(atts.getValue(idx))
-                            href = c.call(href)
-                            newatts.setValue(idx, href.toASCIIString())
-                        } catch (URISyntaxException ignore) {
-                        }
+                int idx = -1;
+                switch (localName) {
+                    case 'a':
+                        idx = atts.getIndex('href')
+                        break;
+                    case 'img':
+                        idx = atts.getIndex('src')
+                        break;
+                }
+                if (idx != -1) {
+                    newatts = new AttributesImpl(atts)
+                    try {
+                        URI origURI = new URI(atts.getValue(idx))
+                        URI newURI = c.call(origURI, localName)
+                        newatts.setValue(idx, newURI.toASCIIString())
+                    } catch (URISyntaxException ignore) {
                     }
                 }
                 super.startElement(uri, localName, qName, newatts != null ? newatts :atts)

Modified: httpcomponents/project-release-tools/trunk/site.gradle
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/site.gradle?rev=1517829&r1=1517828&r2=1517829&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/site.gradle (original)
+++ httpcomponents/project-release-tools/trunk/site.gradle Tue Aug 27 14:26:18 2013
@@ -67,7 +67,8 @@ task stage(dependsOn: prepareStage) << {
                 with siteContent(file("${release.localDir}/${submodule}"))
             }
         }
-        fixLinks(release, file("${prepareStage.localDir}/${releaseSeries}"))
+        fixLinks(release, file(releaseStaging))
+        rewriteSiteCss(release, file(releaseStaging))
     }
     println("Copying content ${website.pom.artifactId}:${website.pom.version} to ${prepareStage.localDir}")
     copy {
@@ -97,7 +98,7 @@ void fixLinks(HCProject hcProject, File 
     // Deal with crappy links generated by Maven Site Plugin
     project.fileTree(dir: dstDir, include: '*.html').each {
         File f ->
-            Html.rewriteLinks(f, { URI href ->
+            Html.rewriteLinks(f, { URI href, String localName ->
                 if (!href.isAbsolute()) {
                     def m1 = href.path =~ /^..(\/..\/scp:\/people.apache.org\/www)?\/hc.apache.org\//
                     if (m1.find()) {
@@ -111,12 +112,15 @@ void fixLinks(HCProject hcProject, File 
     hcProject.pom.modules.each { String submodule ->
         project.fileTree(dir: new File(dstDir, submodule), include: '*.html').each {
             File f ->
-                Html.rewriteLinks(f, { URI href ->
+                Html.rewriteLinks(f, { URI href, String localName ->
                     if (!href.isAbsolute()) {
                         def m1 = href.path =~ /^..\/..(\/..\/scp:\/people.apache.org\/www)?\/hc.apache.org\//
                         if (m1.find()) {
                             return new URI(m1.replaceFirst('../../'))
                         }
+                        if (href.path == '../images/logos/httpcomponents.png') {
+                            return new URI('../../images/logos/httpcomponents.png')
+                        }
                     }
                     return href
                 })
@@ -124,3 +128,28 @@ void fixLinks(HCProject hcProject, File 
     }
 
 }
+
+void rewriteSiteCss(HCProject hcProject, File dstDir) {
+    File siteCss = new File(dstDir, 'css/site.css')
+    if (siteCss.exists()) {
+        Writer w = siteCss.newWriter()
+        try {
+            w  << '@import url("../../css/hc-maven.css");'
+        } finally {
+            w.close()
+        }
+    }
+    hcProject.pom.modules.each { String submodule ->
+        File moduleDstDir = new File(dstDir, submodule)
+        File moduleSiteCss = new File(moduleDstDir, 'css/site.css')
+        if (moduleSiteCss.exists()) {
+            Writer w = moduleSiteCss.newWriter()
+            try {
+                w  << '@import url("../../../css/hc-maven.css");'
+            } finally {
+                w.close()
+            }
+        }
+    }
+
+}



Mime
View raw message