Changeset 1512 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2009-03-24T14:49:19+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/WikiReader.java
r1483 r1512 6 6 import java.io.InputStreamReader; 7 7 import java.net.URL; 8 9 import org.openstreetmap.josm.Main; 8 10 9 11 /** … … 20 22 } 21 23 24 public WikiReader() { 25 this.baseurl = Main.pref.get("help.baseurl", "http://josm.openstreetmap.de"); 26 } 27 22 28 /** 23 29 * Read the page specified by the url and return the content. … … 32 38 BufferedReader in = new BufferedReader(new InputStreamReader(new URL(url).openStream(), "utf-8")); 33 39 if (url.startsWith(baseurl) && !url.endsWith("?format=txt")) 34 return readFromTrac(in , url);40 return readFromTrac(in); 35 41 return readNormal(in); 42 } 43 44 public String readLang(String text) { 45 String languageCode = Main.getLanguageCodeU(); 46 String url = baseurl + "/wiki/"+languageCode+text; 47 String res = ""; 48 try { 49 res = readFromTrac(new BufferedReader(new InputStreamReader(new URL(url).openStream(), "utf-8"))); 50 } catch (IOException ioe) {} 51 if(res.length() == 0 && languageCode.length() != 0) 52 { 53 url = baseurl + "/wiki/"+text; 54 try { 55 res = readFromTrac(new BufferedReader(new InputStreamReader(new URL(url).openStream(), "utf-8"))); 56 } catch (IOException ioe) {} 57 } 58 return res; 36 59 } 37 60 … … 45 68 } 46 69 47 private String readFromTrac(BufferedReader in , String url) throws IOException {70 private String readFromTrac(BufferedReader in) throws IOException { 48 71 boolean inside = false; 49 72 boolean transl = false; … … 66 89 transl = false; 67 90 } 91 if(b.indexOf(" Describe ") >= 0) 92 return ""; 68 93 return "<html>" + b + "</html>"; 69 94 }
Note:
See TracChangeset
for help on using the changeset viewer.