cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nicola...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/bean CocoonBean.java
Date Fri, 28 Mar 2003 12:55:43 GMT
nicolaken    2003/03/28 04:55:43

  Modified:    src/java/org/apache/cocoon/sitemap LinkGatherer.java
               src/java/org/apache/cocoon/bean CocoonBean.java
  Log:
  Minor enhancements and and fixes the bug where page
  references with anchors (e.g. page.html#anchor) break the
  confirmExtensions=false option.
  
  Thanks to Upayavira (uv-at-upaya.co.uk) :-)
  
  Revision  Changes    Path
  1.2       +14 -4     cocoon-2.1/src/java/org/apache/cocoon/sitemap/LinkGatherer.java
  
  Index: LinkGatherer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/sitemap/LinkGatherer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LinkGatherer.java	18 Mar 2003 15:23:49 -0000	1.1
  +++ LinkGatherer.java	28 Mar 2003 12:55:42 -0000	1.2
  @@ -82,13 +82,17 @@
   
       public void simpleLink(String href, String role, String arcrole, String title, String
show, String actuate, String uri,
           String name, String raw, Attributes attr) throws SAXException {
  -            this.addLink(href);
  +            if (!this.links.contains(href)){
  +                this.addLink(href);
  +            }
               super.simpleLink(href, role, arcrole, title, show, actuate, uri, name, raw,
attr);
       }
   
       public void startLocator(String href, String role, String title, String label, String
uri, String name, String raw,
           Attributes attr) throws SAXException {
  -            this.addLink(href);
  +            if (!this.links.contains(href)){
  +                this.addLink(href);
  +            }
               super.startLocator(href, role, title, label, uri, name, raw, attr);
       }
       private void addLink(String href) {
  @@ -98,6 +102,12 @@
           if (href.startsWith("mailto:")) return;
           if (href.startsWith("news:")) return;
           if (href.startsWith("javascript:")) return;
  -        this.links.add(href);
  +
  +        int anchorPos = href.indexOf('#');
  +        if (anchorPos == -1) {
  +            this.links.add(href);
  +        } else {
  +            this.links.add(href.substring(0, anchorPos));
  +        }
       }
   }
  
  
  
  1.3       +33 -32    cocoon-2.1/src/java/org/apache/cocoon/bean/CocoonBean.java
  
  Index: CocoonBean.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/bean/CocoonBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CocoonBean.java	18 Mar 2003 15:23:28 -0000	1.2
  +++ CocoonBean.java	28 Mar 2003 12:55:42 -0000	1.3
  @@ -645,44 +645,44 @@
           final HashMap translatedLinks = new HashMap();
           final ArrayList gatheredLinks = new ArrayList();
   
  -        if (followLinks && confirmExtension) {        
  -        final Iterator i = this.getLinks(deparameterizedURI, parameters).iterator();
  +        if (followLinks && confirmExtension) {
  +            final Iterator i = this.getLinks(deparameterizedURI, parameters).iterator();
   
  -        while (i.hasNext()) {
  -            String link = (String) i.next();
  -            // Fix relative links starting with "?"
  -            String relativeLink = link;
  -            if (relativeLink.startsWith("?")) {
  -                relativeLink = pageURI + relativeLink;
  -            }
  +            while (i.hasNext()) {
  +                String link = (String) i.next();
  +                // Fix relative links starting with "?"
  +                String relativeLink = link;
  +                if (relativeLink.startsWith("?")) {
  +                    relativeLink = pageURI + relativeLink;
  +                }
   
  -            String absoluteLink = NetUtils.normalize(NetUtils.absolutize(path, relativeLink));
  -            {
  -                final TreeMap p = new TreeMap();
  -                absoluteLink = NetUtils.parameterize(NetUtils.deparameterize(absoluteLink,
p), p);
  -            }
  -            String translatedAbsoluteLink = (String)allTranslatedLinks.get(absoluteLink);
  -            if (translatedAbsoluteLink == null) {
  -                try {
  -                    translatedAbsoluteLink = this.translateURI(absoluteLink);
  -                    log.info("  Link translated: " + absoluteLink);
  -                    allTranslatedLinks.put(absoluteLink, translatedAbsoluteLink);
  -                    absoluteLinks.add(absoluteLink);
  -                } catch (ProcessingException pe) {
  -                    printBroken(absoluteLink, pe.getMessage());
  +                String absoluteLink = NetUtils.normalize(NetUtils.absolutize(path, relativeLink));
  +                {
  +                    final TreeMap p = new TreeMap();
  +                    absoluteLink = NetUtils.parameterize(NetUtils.deparameterize(absoluteLink,
p), p);
  +                }
  +                String translatedAbsoluteLink = (String)allTranslatedLinks.get(absoluteLink);
  +                if (translatedAbsoluteLink == null) {
  +                    try {
  +                        translatedAbsoluteLink = this.translateURI(absoluteLink);
  +                        log.info("  Link translated: " + absoluteLink);
  +                        allTranslatedLinks.put(absoluteLink, translatedAbsoluteLink);
  +                        absoluteLinks.add(absoluteLink);
  +                    } catch (ProcessingException pe) {
  +                        printBroken(absoluteLink, pe.getMessage());
  +                    }
                   }
  +
  +                // I have to add also broken links to the absolute links
  +                // to be able to generate the "broken link" page
  +                absoluteLinks.add(absoluteLink);
  +                final String translatedRelativeLink = NetUtils.relativize(path, translatedAbsoluteLink);
  +                translatedLinks.put(link, translatedRelativeLink);
               }
   
  -            // I have to add also broken links to the absolute links
  -            // to be able to generate the "broken link" page
  -            absoluteLinks.add(absoluteLink);
  -            final String translatedRelativeLink = NetUtils.relativize(path, translatedAbsoluteLink);
  -            translatedLinks.put(link, translatedRelativeLink);
  +            printInfo("["+translatedLinks.size()+"] ");
           }
   
  -        printInfo("["+translatedLinks.size()+"] ");
  -      }
  -
           try {
               // Process URI
               String file = NetUtils.decodePath(filename);
  @@ -704,6 +704,7 @@
                           }
                           absoluteLinks.add(absoluteLink);
                       }
  +                    printInfo("["+gatheredLinks.size()+"] ");
                   }
   
                   printlnInfo(uri); // (can also output type returned by getPage)
  
  
  

Mime
View raw message