Ignore:
Timestamp:
2012-09-12T19:37:39+12:00 (12 years ago)
Author:
ak19
Message:
  1. Fixed the democlient to work with the new GS3 again: lots of small things had got broken (such as image display, since the metadata being stored was different). 2. Updating the jar files and democlient distribution zip files with the latest working version of this.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/gs3-webservices-java-client/trunk/src/GS3DemoClient/org/greenstone/gs3client/Displays.java

    r15222 r26180  
    8585     * @param imgURL - src URL for a (web) image
    8686     * @return the imgURL parameter enclosed in complete html */
    87     public static String getImgUrlEnclosedInHtml(String imgURL)
     87    public static String getImgUrlEnclosedInHtml(String baseURL, String imgURL)
    8888    {
    89         return "<html><head></head><body><img src="
    90             + imgURL + "></body></html>";
     89        //return "<html><head></head><body><img src=" + imgURL + "></body></html>"; // old Greenstone3
     90
     91        String htmlStr = "<html><head></head><body>";
     92        int index = imgURL.indexOf("<img src=");
     93        if(index != -1) { // if it already contains an image tag
     94        // check if it's a relative url
     95        index = imgURL.indexOf("://", index + "<img src=".length());
     96        if(index == -1) { // relative, so doesn't have a file:// or http(s):// prefix
     97            imgURL = imgURL.replace("<img src=\"", "<img src=\""+baseURL);
     98        }
     99        htmlStr += imgURL;
     100        }
     101        else { // Old GS3: doesn't yet contain an image tag, embed url in img tag
     102        htmlStr = htmlStr + "<img src=" + imgURL + ">";
     103        }
     104        htmlStr += "</body></html>";
     105        return htmlStr;
     106       
    91107    }
    92108   
     
    220236            if(docNode.canBeImage())
    221237                htmlArea.setText(
    222                         getImgUrlEnclosedInHtml(docNode.getImgURL()));
     238                     getImgUrlEnclosedInHtml(client.getBaseURL(), docNode.getImgURL()));
    223239                // JEditorPane does not understand <img />! So use only <img>
    224240            else {
     
    227243                // for the latest exported greenstone colllections
    228244                // into fedora, Greenstone prefixes FG in front of image name...
    229                 htmlArea.setText(getImgUrlEnclosedInHtml(filepath+filename));
     245                htmlArea.setText(getImgUrlEnclosedInHtml(client.getBaseURL(), filepath+filename));
    230246            }
    231247                 
Note: See TracChangeset for help on using the changeset viewer.