A option to replace Accented Chars on Anchor creation
-----------------------------------------------------

                 Key: ROL-1420
                 URL: 
http://opensource.atlassian.com/projects/roller/browse/ROL-1420
             Project: Roller
          Issue Type: New Feature
          Components: Configuration & Settings
            Reporter: Wladimir Boton
            Assignee: Roller Unassigned


The user should have the option to convert all accented characters of a post 
title with equivalent ascii letters to generate the anchor for that post. It is 
easer to type urls. 
My sugestion is to use the sun.text.Normalize library and change the funcion 
createAnchorBase as:

public String createAnchorBase() {
        
        // Use title (minus non-alphanumeric characters)
        String base = null;
        if (!StringUtils.isEmpty(getTitle())) {
            base = Utilities.replaceNonAlphanumeric(getTitle(), ' ').trim();    
        }
        // If we still have no base, then try text (minus non-alphanumerics)
        if (StringUtils.isEmpty(base) && !StringUtils.isEmpty(getText())) {
            base = Utilities.replaceNonAlphanumeric(getText(), ' ').trim();  
        }
        
        if (!StringUtils.isEmpty(base)) {
            
            // Use only the first 4 words
            StringTokenizer toker = new StringTokenizer(base);
            String tmp = null;
            int count = 0;
            while (toker.hasMoreTokens() && count < 5) {
                String s = toker.nextToken();
                s = s.toLowerCase();
                tmp = (tmp == null) ? s : tmp + "_" + s;
                count++;
            }
            String temp = Normalizer.normalize(tmp, Normalizer.DECOMP, 0);
            base = temp.replaceAll("[^\\p{ASCII}]","");
        }
        // No title or text, so instead we will use the items date
        // in YYYYMMDD format as the base anchor
        else {
            base = DateUtil.format8chars(getPubTime());
        }
        
        return base;
    }

Should only to add logic to do the 
            String temp = Normalizer.normalize(tmp, Normalizer.DECOMP, 0);
            base = temp.replaceAll("[^\\p{ASCII}]","");
part when the blog settings Normalize is true.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://opensource.atlassian.com/projects/roller/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to