Changeset 7401 in josm for trunk/src/org/openstreetmap/josm/tools/WikiReader.java
- Timestamp:
- 2014-08-15T17:45:34+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/WikiReader.java
r7033 r7401 36 36 * Read the page specified by the url and return the content. 37 37 * 38 * If the url is within the baseurl path, parse it as an trac wikipage and replace relative 39 * pathes etc.. 38 * If the url is within the baseurl path, parse it as an trac wikipage and replace relative paths etc.. 39 * @param url the URL to read 40 * @return The page as string 40 41 * 41 42 * @throws IOException Throws, if the page could not be loaded. … … 44 45 URL u = new URL(url); 45 46 try (BufferedReader in = Utils.openURLReader(u)) { 46 if (url.startsWith(baseurl) && !url.endsWith("?format=txt")) 47 boolean txt = url.endsWith("?format=txt"); 48 if (url.startsWith(baseurl) && !txt) 47 49 return readFromTrac(in, u); 48 return readNormal(in );50 return readNormal(in, !txt); 49 51 } 50 52 } 51 53 54 /** 55 * Reads the localized version of the given wiki page. 56 * @param text The page title, without locale prefix 57 * @return the localized version of the given wiki page 58 * @throws IOException if any I/O error occurs 59 */ 52 60 public String readLang(String text) throws IOException { 53 61 String languageCode; … … 89 97 } 90 98 91 private String readNormal(BufferedReader in ) throws IOException {99 private String readNormal(BufferedReader in, boolean html) throws IOException { 92 100 StringBuilder b = new StringBuilder(); 93 101 for (String line = in.readLine(); line != null; line = in.readLine()) { … … 96 104 } 97 105 } 98 return "<html>" + b + "</html>";106 return html ? "<html>" + b + "</html>" : b.toString(); 99 107 } 100 108
Note:
See TracChangeset
for help on using the changeset viewer.