Changeset 23968


Ignore:
Timestamp:
2011-04-29T13:19:47+12:00 (13 years ago)
Author:
sjm84
Message:

Several improvements including fixing realistic books and fixing the client-side xslt interface naming issue

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java

    r23790 r23968  
    633633            if (href.indexOf("?")!=-1) {
    634634              String[] parts = StringUtils.split(href, "\\?", -1);
    635               parts[1] = StringUtils.replace(parts[1], ":", "%3A");
    636               href = parts[0]+"?"+parts[1];
     635              if (parts.length == 1)
     636              {
     637                parts[0] = StringUtils.replace(parts[0], ":", "%3A");
     638                href = "?"+parts[0];
     639              }
     640              else
     641              {
     642                parts[1] = StringUtils.replace(parts[1], ":", "%3A");
     643                href = parts[0]+"?"+parts[1];
     644              }
     645             
    637646            }
    638647            a.setAttribute("href", response.encodeURL(href));
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/Collection.java

    r23938 r23968  
    223223        addPlugins(plugin_list);
    224224        if (plugin_list != null){
    225           Element plugin_elem = (Element)GSXML.getNamedElement(plugin_list, GSXML.PLUGIN_ELEM, GSXML.NAME_ATT, "HTMLPlug");
     225          Element plugin_elem = (Element)GSXML.getNamedElement(plugin_list, GSXML.PLUGIN_ELEM, GSXML.NAME_ATT, "HTMLPlugin");
    226226          if (plugin_elem != null) {
    227227            //get the option
    228             Element option_elem = (Element)GSXML.getNamedElement(plugin_elem, GSXML.PARAM_OPTION_ELEM, GSXML.NAME_ATT, "-tidy_html");
     228            Element option_elem = (Element)GSXML.getNamedElement(plugin_elem, GSXML.PARAM_OPTION_ELEM, GSXML.NAME_ATT, "-use_realistic_book");
    229229            if (option_elem != null) {
    230230              useBook = true;
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/DefaultReceptionist.java

    r23815 r23968  
    5252       
    5353        if (coll_name.equals("")) {
    54             coll_name = GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, "p.c").getAttribute(GSXML.VALUE_ATT);
     54            Element pc_param = GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, "p.c");
     55            if(pc_param != null)
     56            {
     57                coll_name = pc_param.getAttribute(GSXML.VALUE_ATT);
     58            }
    5559        }
    5660       
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java

    r23839 r23968  
    205205    else if(excerptTag != null)
    206206    {
     207        /*
    207208        // define a list
    208209       
    209210        Node selectedElement = modifyNodesByTagRecursive(transformed_page, excerptTag);
     211        */
     212       
     213        Node selectedElement = getNodeByTagRecursive(transformed_page, excerptTag);
    210214        return selectedElement;
     215       
    211216    }
    212217    return transformed_page;
     
    285290  protected Node transformPage(Element page) {
    286291   
    287      boolean allowsClientXSLT = (Boolean)config_params.get(GSConstants.ALLOW_CLIENT_SIDE_XSLT);
    288      //System.out.println("Client side transforms allowed? " + allowsClientXSLT);
    289      
    290      // Force it back to traditional
    291      if(!allowsClientXSLT)
    292         config_params.put(GSConstants.INTERFACE_NAME, "traditional");
    293    
    294      Element request = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_REQUEST_ELEM);
    295      String output = request.getAttribute(GSXML.OUTPUT_ATT);   
    296      
    297      String currentInterface = (String)config_params.get(GSConstants.INTERFACE_NAME);
    298      //System.out.println("Current output mode is: " + output + ", current interface name is: " + currentInterface);
    299      
    300      if(allowsClientXSLT) {
    301          if((currentInterface.equals("default") && output.equals("html")) || output.equals("server"))
    302            // Switch the interface
    303            config_params.put(GSConstants.INTERFACE_NAME, "traditional");
    304          else if(currentInterface.equals("traditional") && !output.equals("html"))
    305            // The reverse needs to happen too
    306            config_params.put(GSConstants.INTERFACE_NAME, "default");
     292    boolean allowsClientXSLT = (Boolean)config_params.get(GSConstants.ALLOW_CLIENT_SIDE_XSLT);
     293    //System.out.println("Client side transforms allowed? " + allowsClientXSLT);
     294
     295    String currentInterface = (String)config_params.get(GSConstants.INTERFACE_NAME);
     296
     297    Element request = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_REQUEST_ELEM);
     298    String output = request.getAttribute(GSXML.OUTPUT_ATT);
     299
     300    //System.out.println("Current output mode is: " + output + ", current interface name is: " + currentInterface);
     301
     302    if(allowsClientXSLT) {
     303        if(!currentInterface.endsWith(GSConstants.CLIENT_SIDE_XSLT_INTERFACE_SUFFIX) && output.equals("html"))
     304        {
     305            System.out.println("output is html and we are not currently using a client side version, switching");
     306            // Switch the interface
     307            config_params.put(GSConstants.INTERFACE_NAME, currentInterface.concat(GSConstants.CLIENT_SIDE_XSLT_INTERFACE_SUFFIX));
     308        }
     309        else if((currentInterface.endsWith(GSConstants.CLIENT_SIDE_XSLT_INTERFACE_SUFFIX) && !output.equals("html")) || output.equals("server"))
     310        {
     311            // The reverse needs to happen too
     312            config_params.put(GSConstants.INTERFACE_NAME, currentInterface.substring(0, currentInterface.length() - GSConstants.CLIENT_SIDE_XSLT_INTERFACE_SUFFIX.length()));
     313        }
     314    }
     315    else if (currentInterface.endsWith(GSConstants.CLIENT_SIDE_XSLT_INTERFACE_SUFFIX))
     316    {
     317        config_params.put(GSConstants.INTERFACE_NAME, currentInterface.substring(0, currentInterface.length() - GSConstants.CLIENT_SIDE_XSLT_INTERFACE_SUFFIX.length()));
    307318    }
    308319   
     
    773784    String stylesheet = GSFile.stylesheetFile(GlobalProperties.getGSDL3Home(), (String)this.config_params.get(GSConstants.SITE_NAME), collection, (String)this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces, name);
    774785    if (stylesheet==null) {
    775       logger.info(" cant find stylesheet for "+name);
    776     }
    777     logger.error("stylesheet:"+stylesheet);
     786      logger.info(" Can't find stylesheet for "+name);
     787    }
     788    logger.debug("Stylesheet: "+stylesheet);
    778789    return stylesheet;
    779790  }
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSConstants.java

    r23791 r23968  
    2828    public static final String DEFAULT_LANG = "default_lang";
    2929    public static final String ALLOW_CLIENT_SIDE_XSLT = "allow_client_side_xslt";
     30    public static final String CLIENT_SIDE_XSLT_INTERFACE_SUFFIX = "-client-xslt";
    3031
    3132    public static final String META_RELATION_SEP = "_";
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSParams.java

    r23269 r23968  
    5050    public static final String EXPAND_DOCUMENT = "ed";
    5151    public static final String EXPAND_CONTENTS = "ec";
     52    public static final String REALISTIC_BOOK = "book";
    5253
    5354  // used for filtering out a piece of the final page
     
    8081    addParameter(EXPAND_DOCUMENT, false);
    8182    addParameter(EXPAND_CONTENTS, false);
     83    addParameter(REALISTIC_BOOK, false);   
     84   
    8285    //addParameter();
    8386    // ugly hack so we don't save the extlink param
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java

    r23791 r23968  
    687687  public static void addParametersToList(Document owner, Element param_list,
    688688    HashMap params) {
     689    if (params == null)
     690    {
     691        return;
     692    }
     693   
    689694    Set items = params.entrySet();
    690695    Iterator i = items.iterator();
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java

    r23791 r23968  
    277277    }
    278278   
     279    public static String hashToSectionId(String hashString)
     280    {
     281        if(hashString == null || hashString.length() == 0 || !hashString.startsWith("HASH")) {return "";}
     282       
     283        int firstDotIndex = hashString.indexOf(".");
     284        if(firstDotIndex == -1)
     285        {   
     286            return "";
     287        }
     288       
     289        String sectionString = hashString.substring(firstDotIndex + 1);
     290       
     291        return sectionString;
     292    }
     293   
     294    public static String hashToDepthClass(String hashString)
     295    {
     296        if(hashString == null || hashString.length() == 0 || !hashString.startsWith("HASH")) {return "";}
     297       
     298        String sectionString = hashToSectionId(hashString);
     299       
     300        int count = sectionString.split("\\.").length;
     301       
     302        if (sectionString.equals(""))
     303        {
     304            return "sectionHeaderDepthTitle";
     305        }
     306        else
     307        {
     308            return "sectionHeaderDepth" + count;
     309        }
     310    }
    279311}
    280312
Note: See TracChangeset for help on using the changeset viewer.