Changeset 5868 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2013-04-15T19:12:01+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r5831 r5868 51 51 import org.openstreetmap.josm.tools.I18n; 52 52 import org.openstreetmap.josm.tools.ImageProvider; 53 import org.openstreetmap.josm.tools.Utils; 53 54 54 55 /** … … 292 293 System.out.println("Reading preferences from " + i); 293 294 try { 294 URL url = new URL(i); 295 config.openAndReadXML(url.openStream()); 295 config.openAndReadXML(Utils.openURL(new URL(i))); 296 296 } catch (Exception ex) { 297 297 throw new RuntimeException(ex); -
trunk/src/org/openstreetmap/josm/gui/help/HelpContentReader.java
r5587 r5868 21 21 * It also has to be <strong>transformed</strong> because the internal help browser required slightly 22 22 * different HTML than what is provided by the Wiki. 23 *24 * @see WikiReader25 23 */ 26 public class HelpContentReader { 27 28 /** the base url */ 29 private String baseUrl; 24 public class HelpContentReader extends WikiReader { 30 25 31 26 /** … … 35 30 */ 36 31 public HelpContentReader(String baseUrl) { 37 this.baseUrl = baseUrl;32 super(baseUrl); 38 33 } 39 34 … … 90 85 */ 91 86 protected String prepareHelpContent(BufferedReader in, boolean dotest) throws HelpContentReaderException { 92 boolean isInContent = false; 93 boolean isInTranslationsSideBar = false; 94 boolean isExistingHelpPage = false; 95 StringBuffer sball = new StringBuffer(); 96 StringBuffer sb = new StringBuffer(); 87 String s = ""; 97 88 try { 98 for (String line = in.readLine(); line != null; line = in.readLine()) { 99 sball.append(line); 100 sball.append("\n"); 101 if (line.contains("<div id=\"searchable\">")) { 102 isInContent = true; 103 } else if (line.contains("<div class=\"wiki-toc trac-nav\"")) { 104 isInTranslationsSideBar = true; 105 } else if (line.contains("<div class=\"wikipage searchable\">")) { 106 isInContent = true; 107 } else if (line.contains("<div class=\"buttons\">")) { 108 isInContent = false; 109 } else if (line.contains("<h3>Attachments</h3>")) { 110 isInContent = false; 111 } else if (line.contains("<div id=\"attachments\">")) { 112 isInContent = false; 113 } else if (line.contains("<div class=\"trac-modifiedby\">")) { 114 continue; 115 } else if (line.contains("<input type=\"submit\" name=\"attachfilebutton\"")) { 116 // heuristic: if we find a button for uploading images we are in an 117 // existing pages. Otherwise this is probably the stub page for a not yet 118 // existing help page 119 isExistingHelpPage = true; 120 } 121 if (isInContent && !isInTranslationsSideBar) { 122 // add a border="0" attribute to images, otherwise the internal help browser 123 // will render a thick border around images inside an <a> element 124 // 125 // Also make sure image URLs are absolute 126 // 127 line = line.replaceAll("<img ([^>]*)src=\"/", "<img border=\"0\" \\1src=\"" + baseUrl + "/").replaceAll("href=\"/", 128 "href=\"" + baseUrl + "/").replaceAll(" />", ">"); 129 sb.append(line); 130 sb.append("\n"); 131 } else if (isInTranslationsSideBar && line.contains("</div>")) { 132 isInTranslationsSideBar = false; 133 } 134 } 89 s = readFromTrac(in); 135 90 } catch(IOException e) { 136 91 throw new HelpContentReaderException(e); 137 92 } 138 if(!dotest && sb.length() == 0) 139 sb = sball; 140 else if (dotest && !isExistingHelpPage) 93 if(dotest && s.isEmpty()) 141 94 throw new MissingHelpContentException(); 142 sb.insert(0, "<html>"); 143 sb.append("<html>"); 144 return sb.toString(); 95 return s; 145 96 } 146 97 } -
trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
r5839 r5868 77 77 import org.openstreetmap.josm.io.OsmTransferException; 78 78 import org.openstreetmap.josm.io.UTFInputStreamReader; 79 import org.openstreetmap.josm.tools.Utils; 79 80 import org.xml.sax.InputSource; 80 81 import org.xml.sax.SAXException; … … 321 322 protected byte[] updateData() throws IOException { 322 323 URL u = getAttributionUrl(); 323 UTFInputStreamReader in = UTFInputStreamReader.create( u.openStream(), "utf-8");324 UTFInputStreamReader in = UTFInputStreamReader.create(Utils.openURL(u), "utf-8"); 324 325 String r = new Scanner(in).useDelimiter("\\A").next(); 325 326 in.close();
Note:
See TracChangeset
for help on using the changeset viewer.