Changeset 5936 in josm
- Timestamp:
- 2013-05-07T13:46:58+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/help/HelpContentReader.java
r5915 r5936 47 47 BufferedReader in = null; 48 48 try { 49 con = Utils.openHttpConnection(new URL(helpTopicUrl)); 49 URL u = new URL(helpTopicUrl); 50 con = Utils.openHttpConnection(u); 50 51 con.connect(); 51 52 in = new BufferedReader(new InputStreamReader(con.getInputStream(),"utf-8")); 52 return prepareHelpContent(in, dotest); 53 return prepareHelpContent(in, dotest, u); 53 54 } catch(MalformedURLException e) { 54 55 throw new HelpContentReaderException(e); … … 79 80 * @throws HelpContentReaderException thrown if an exception occurs 80 81 * @throws MissingHelpContentException thrown, if the content read isn't a help page 82 * @since 5935 81 83 */ 82 protected String prepareHelpContent(BufferedReader in, boolean dotest) throws HelpContentReaderException { 84 protected String prepareHelpContent(BufferedReader in, boolean dotest, URL url) throws HelpContentReaderException { 83 85 String s = ""; 84 86 try { 85 s = readFromTrac(in); 87 s = readFromTrac(in, url); 86 88 } catch(IOException e) { 87 89 throw new HelpContentReaderException(e); -
trunk/src/org/openstreetmap/josm/tools/WikiReader.java
r5915 r5936 35 35 */ 36 36 public String read(String url) throws IOException { 37 BufferedReader in = Utils.openURLReader(new URL(url)); 37 URL u = new URL(url); 38 BufferedReader in = Utils.openURLReader(u); 38 39 try { 39 40 if (url.startsWith(baseurl) && !url.endsWith("?format=txt")) 40 return readFromTrac(in); 41 return readFromTrac(in, u); 41 42 return readNormal(in); 42 43 } finally { … … 78 79 BufferedReader in = Utils.openURLReader(url); 79 80 try { 80 return readFromTrac(in); 81 return readFromTrac(in, url); 81 82 } finally { 82 83 Utils.close(in); … … 94 95 } 95 96 96 protected String readFromTrac(BufferedReader in) throws IOException { 97 protected String readFromTrac(BufferedReader in, URL url) throws IOException { 97 98 boolean inside = false; 98 99 boolean transl = false; … … 119 120 // will render a thick border around images inside an <a> element 120 121 // 121 b += line.replaceAll("<img ", "<img border=\"0\" ").replaceAll(" />", ">") + "\n"; 122 b += line.replaceAll("<img ", "<img border=\"0\" ") 123 .replaceAll("href=\"/", "href=\"" + baseurl + "/") 124 .replaceAll(" />", ">") 125 + "\n"; 122 126 } else if (transl && line.contains("</div>")) { 123 127 transl = false; … … 130 134 || b.indexOf(" does not exist. You can create it here.</p>") >= 0) 131 135 return ""; 132 return "<html><base href=\""+ baseurl+"\"> " + b + "</html>";136 return "<html><base href=\""+url.toExternalForm() +"\"> " + b + "</html>"; 133 137 } 134 138 }
Note:
See TracChangeset
for help on using the changeset viewer.