Changeset 6588
- Timestamp:
- 10/04/10 19:24:24 (5 months ago)
- Location:
- trunk
- Files:
-
- 6 modified
-
AWT/AWT_www.cxx (modified) (3 diffs)
-
AWT/Makefile (modified) (1 diff)
-
HELP_SOURCE/oldhelp/props_www.hlp (modified) (2 diffs)
-
MERGE/Makefile (modified) (1 diff)
-
WINDOW/AW_global_awars.cxx (modified) (2 diffs)
-
WINDOW/aw_global_awars.hxx (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/AWT/AWT_www.cxx
r6490 r6588 15 15 #include <aw_awars.hxx> 16 16 #include <arbdbt.h> 17 #include <inline.h> 18 #include <static_assert.h> 17 19 18 20 #define WWW_COUNT 10 19 // #define AWAR_WWW_BROWSER "www/browser" // now defined by ARB_init_global_awars()20 21 #define AWAR_WWW_SELECT "www/url_select" 21 #define AWAR_WWW_0 "www/url_0/srt"22 #define AWAR_WWW_1 "www/url_0/srt"23 #define AWAR_WWW_2 "www/url_0/srt"24 22 #define AWAR_WWW_SELECT_TEMPLATE "www/url_%i/select" 25 23 #define AWAR_WWW_TEMPLATE "www/url_%i/srt" 26 24 #define AWAR_WWW_DESC_TEMPLATE "www/url_%i/desc" 27 25 28 26 inline char *extract_url_host(const char *templ) { 27 const char *url_start = strstr(templ, "\"http://"); 28 if (url_start) { 29 const char *host_start = url_start+8; 30 const char *slash = strchr(host_start, '/'); 31 32 if (slash) return GB_strpartdup(host_start, slash-1); 33 } 34 return NULL; 35 } 36 37 inline bool url_host_matches(const char *templ1, const char *templ2) { 38 bool matches = false; 39 char *url1 = extract_url_host(templ1); 40 if (url1) { 41 char *url2 = extract_url_host(templ2); 42 matches = url1 && url2 && ARB_stricmp(url1, url2) == 0; 43 free(url2); 44 } 45 free(url1); 46 return matches; 47 } 29 48 30 49 void awt_create_aww_vars(AW_root *aw_root, AW_default aw_def) { 31 int i; 32 for (i=0; i<WWW_COUNT; i++) { 33 const char *awar_name; 34 35 awar_name = GBS_global_string(AWAR_WWW_TEMPLATE, i); aw_root->awar_string(awar_name, i==WWW_COUNT-1 ? "\"http://www.ebi.ac.uk/cgi-bin/emblfetch?\";readdb(acc)" : "", aw_def); 36 awar_name = GBS_global_string(AWAR_WWW_DESC_TEMPLATE, i); aw_root->awar_string(awar_name, i==WWW_COUNT-1 ? "EMBL example" : "", aw_def); 37 awar_name = GBS_global_string(AWAR_WWW_SELECT_TEMPLATE, i); aw_root->awar_int(awar_name, 0, aw_def); 38 } 39 40 aw_root->awar_int(AWAR_WWW_SELECT, 0, aw_def); 41 50 struct Example { 51 const char *descr; 52 const char *templ; 53 } example[] = { 54 { "EMBL example", "\"http://www.ebi.ac.uk/ena/data/view/\";readdb(acc)" }, 55 { "SILVA example", "\"http://www.arb-silva.de/browser/ssu/\";readdb(acc)" }, 56 { "Google example", "\"http://www.google.com/search?q=\";readdb(full_name);|srt(\": =+\")" } 57 }, empty = { "", "" }; 58 59 const int DEFAULT_SELECT = 1; // SILVA 60 const int EXAMPLE_COUNT = sizeof(example)/sizeof(*example); 61 COMPILE_ASSERT(EXAMPLE_COUNT <= WWW_COUNT); 62 63 bool example_url_seen[EXAMPLE_COUNT]; 64 for (int x = 0; x<EXAMPLE_COUNT; ++x) example_url_seen[x] = false; 65 66 AW_awar *awar_templ[WWW_COUNT]; 67 AW_awar *awar_descr[WWW_COUNT]; 68 bool is_empty[WWW_COUNT]; 69 70 for (int i = 0; i<WWW_COUNT; ++i) { 71 const Example& curr = i<EXAMPLE_COUNT ? example[i] : empty; 72 const char *awar_name; 73 74 awar_name = GBS_global_string(AWAR_WWW_TEMPLATE, i); 75 awar_templ[i] = aw_root->awar_string(awar_name, curr.templ, aw_def); 76 77 awar_name = GBS_global_string(AWAR_WWW_DESC_TEMPLATE, i); 78 awar_descr[i] = aw_root->awar_string(awar_name, curr.descr, aw_def); 79 80 const char *templ = awar_templ[i]->read_char_pntr(); 81 const char *descr = awar_descr[i]->read_char_pntr(); 82 83 is_empty[i] = !templ[0] && !descr[0]; 84 if (!is_empty[i]) { 85 for (int x = 0; x<EXAMPLE_COUNT; ++x) { 86 if (!example_url_seen[x]) { 87 example_url_seen[x] = url_host_matches(templ, example[x].templ); 88 } 89 } 90 } 91 92 awar_name = GBS_global_string(AWAR_WWW_SELECT_TEMPLATE, i); 93 aw_root->awar_int(awar_name, 0, aw_def); 94 } 95 96 // insert missing examples 97 for (int x = 0; x<EXAMPLE_COUNT; ++x) { 98 if (!example_url_seen[x]) { 99 for (int i = 0; i<WWW_COUNT; ++i) { 100 if (is_empty[i]) { 101 awar_templ[i]->write_string(example[x].templ); 102 awar_descr[i]->write_string(example[x].descr); 103 is_empty[i] = false; 104 break; 105 } 106 } 107 } 108 } 109 110 aw_root->awar_int(AWAR_WWW_SELECT, DEFAULT_SELECT, aw_def); 42 111 awt_assert(ARB_global_awars_initialized()); 43 112 } … … 64 133 error = awt_open_ACISRT_URL_by_gbd(aw_root, gb_main, gbd, name, url_srt); 65 134 66 delete url_srt;135 free(url_srt); 67 136 return error; 68 137 } … … 76 145 77 146 if (!gb_species) { 78 error = GB _export_errorf("Cannot find species '%s'", selected_species);147 error = GBS_global_string("Cannot find species '%s'", selected_species); 79 148 } 80 149 else { -
trunk/AWT/Makefile
r6490 r6588 420 420 AWT_www.o: $(ARBHOME)/INCLUDE/aw_window.hxx 421 421 AWT_www.o: $(ARBHOME)/INCLUDE/dupstr.h 422 AWT_www.o: $(ARBHOME)/INCLUDE/inline.h 422 423 AWT_www.o: $(ARBHOME)/INCLUDE/smartptr.h 424 AWT_www.o: $(ARBHOME)/INCLUDE/static_assert.h -
trunk/HELP_SOURCE/oldhelp/props_www.hlp
r2986 r6588 24 24 EXAMPLES Here are some search examples (URL-Entries): 25 25 26 Retrieve from EMBL-Database:27 "http://www.ebi.ac.uk/cgi-bin/emblfetch?";readdb(acc)26 Search in ARB-SILVA: 27 "http://www.arb-silva.de/browser/ssu/";readdb(acc) 28 28 29 Search Medline for related information:30 "http://www.ncbi.nlm.nih.gov/htbin-post/Entrez/query?uid=";readdb(medline_id);"&form=6&db=m&Dopt=b" 29 Search in EMBL: 30 "http://www.ebi.ac.uk/ena/data/view/";readdb(acc) 31 31 32 32 Search the Web for full-name using google: 33 "http://www.google.com/search?q=";readdb(full_name); "&ie=ISO-8859-1&hl=de&btnG=Google-Suche&meta="|srt(": =+")33 "http://www.google.com/search?q=";readdb(full_name);|srt(": =+")" 34 34 35 35 … … 38 38 preferred internet browser. 39 39 40 Netscape user enter:40 Generic methods: 41 41 42 (netscape -remote 'openURL($(URL))' || netscape '$(URL)') &42 xdg-open "$(URL)" 43 43 44 Opera users enter one of: 45 46 opera -remote 'openURL($(URL))' & 47 48 opera -remote 'openURL($(URL),new-window)' & 49 50 44 open "$(URL)" (OSX) 51 45 52 46 WARNINGS We are not responsible for any content you retrieve by using 53 this function. Only use this at your own responsibility.47 this function. Use this at your own responsibility. 54 48 55 49 BUGS No bugs known -
trunk/MERGE/Makefile
r6566 r6588 224 224 225 225 MG_preserves.o: merge.hxx 226 MG_preserves.o: MG_adapt_ali.hxx 226 227 MG_preserves.o: mg_merge.hxx 227 228 MG_preserves.o: $(ARBHOME)/INCLUDE/ad_k_prot.h -
trunk/WINDOW/AW_global_awars.cxx
r6385 r6588 103 103 } 104 104 105 #if defined(DARWIN) 106 #define OPENURL "open" 107 #else 108 #define OPENURL "xdg-open" 109 #endif // DARWIN 110 105 111 GB_ERROR ARB_init_global_awars(AW_root *aw_root, AW_default aw_def, GBDATA *gb_main) { 106 112 aw_assert(!initialized); // don't call twice! … … 110 116 gb_main4awar = gb_main; 111 117 112 GB_ERROR error = aw_root->awar_string(AWAR_WWW_BROWSER, "(netscape -remote 'openURL($(URL))' || netscape '$(URL)') &", aw_def)->make_global();118 GB_ERROR error = aw_root->awar_string(AWAR_WWW_BROWSER, OPENURL " \"$(URL)\"", aw_def)->make_global(); 113 119 114 120 if (!error) { -
trunk/WINDOW/aw_global_awars.hxx
r5675 r6588 16 16 #define AW_GLOBAL_AWARS_HXX 17 17 18 #define AWAR_WWW_BROWSER "www/browse r" // how to call the users browser18 #define AWAR_WWW_BROWSER "www/browse_cmd" // how to call the users browser 19 19 20 20 #else
