Ignore:
Timestamp:
2009-03-10T17:07:46+01:00 (16 years ago)
Author:
stoecker
Message:

added user agent

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/WikiReader.java

    r1475 r1480  
    1414public class WikiReader {
    1515
    16     public static final String JOSM_EXTERN = "http://josm-extern.";
    1716    private final String baseurl;
    1817
     
    3837
    3938    private String readNormal(BufferedReader in) throws IOException {
    40         String b = "<html>";
     39        String b = "";
    4140        for (String line = in.readLine(); line != null; line = in.readLine()) {
    42             line = adjustText(line);
    4341            if(!line.contains("[[TranslatedPages]]"))
    44               b += line + "\n";
     42                b += line.replaceAll(" />", ">") + "\n";
    4543        }
    46         return b;
     44        return "<html>" + b + "</html>";
    4745    }
    4846
    4947    private String readFromTrac(BufferedReader in, String url) throws IOException {
    5048        boolean inside = false;
    51         StringBuilder b = new StringBuilder("<html>");
     49        String b = "";
    5250        for (String line = in.readLine(); line != null; line = in.readLine()) {
    5351            if (line.contains("<div id=\"searchable\">"))
     
    5856                inside = false;
    5957            if (inside) {
    60                 line = line.replaceAll("<img src=\"/", "<img src=\""+baseurl+"/");
    61                 line = line.replaceAll("href=\"/", "href=\""+baseurl+"/");
    62                 if (!line.contains("$"))
    63                     line = line.replaceAll("<p>Describe \"([^\"]+)\" here</p>", "<p>Describe \"$1\" <a href=\""+JOSM_EXTERN+url.substring(7)+"\">here</a></p>");
    64                 line = adjustText(line);
    65                 b.append(line);
    66                 b.append("\n");
     58                b += line.replaceAll("<img src=\"/", "<img src=\""+baseurl+"/")
     59                         .replaceAll("href=\"/", "href=\""+baseurl+"/")
     60                         .replaceAll(" />", ">") + "\n";
    6761            }
    6862        }
    69         b.append("</html>");
    70         return b.toString();
    71     }
    72 
    73     private String adjustText(String text) {
    74         text = text.replaceAll(" />", ">");
    75         return text;
     63        return "<html>" + b + "</html>";
    7664    }
    7765}
Note: See TracChangeset for help on using the changeset viewer.