Changeset 6588

Show
Ignore:
Timestamp:
10/04/10 19:24:24 (5 months ago)
Author:
westram
Message:
  • changed default browse-url-command to 'xdg-open' ('open' on DARWIN). [thx elmar]
    • renamed AWAR_WWW_BROWSER to force update in userland
  • added 2 additional example URLs (SILVA + google) [thx elmar]
  • parse existing URLs and force insertion of missing examples if there are unused WWW patterns
  • fixed mismatched delete
  • updated WWW help
Location:
trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/AWT/AWT_www.cxx

    r6490 r6588  
    1515#include <aw_awars.hxx> 
    1616#include <arbdbt.h> 
     17#include <inline.h> 
     18#include <static_assert.h> 
    1719 
    1820#define WWW_COUNT                10 
    19 // #define AWAR_WWW_BROWSER "www/browser" // now defined by ARB_init_global_awars() 
    2021#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" 
    2422#define AWAR_WWW_SELECT_TEMPLATE "www/url_%i/select" 
    2523#define AWAR_WWW_TEMPLATE        "www/url_%i/srt" 
    2624#define AWAR_WWW_DESC_TEMPLATE   "www/url_%i/desc" 
    2725 
    28  
     26inline 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 
     37inline 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} 
    2948 
    3049void 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); 
    42111    awt_assert(ARB_global_awars_initialized()); 
    43112} 
     
    64133    error                        = awt_open_ACISRT_URL_by_gbd(aw_root, gb_main, gbd, name, url_srt); 
    65134 
    66     delete url_srt; 
     135    free(url_srt); 
    67136    return error; 
    68137} 
     
    76145 
    77146    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); 
    79148    } 
    80149    else { 
  • trunk/AWT/Makefile

    r6490 r6588  
    420420AWT_www.o: $(ARBHOME)/INCLUDE/aw_window.hxx 
    421421AWT_www.o: $(ARBHOME)/INCLUDE/dupstr.h 
     422AWT_www.o: $(ARBHOME)/INCLUDE/inline.h 
    422423AWT_www.o: $(ARBHOME)/INCLUDE/smartptr.h 
     424AWT_www.o: $(ARBHOME)/INCLUDE/static_assert.h 
  • trunk/HELP_SOURCE/oldhelp/props_www.hlp

    r2986 r6588  
    2424EXAMPLES        Here are some search examples (URL-Entries): 
    2525 
    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) 
    2828 
    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) 
    3131 
    3232                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(": =+")" 
    3434 
    3535 
     
    3838                preferred internet browser. 
    3939 
    40                 Netscape user enter: 
     40                Generic methods: 
    4141 
    42                     (netscape -remote 'openURL($(URL))' || netscape '$(URL)') & 
     42                    xdg-open "$(URL)" 
    4343 
    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) 
    5145 
    5246WARNINGS        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. 
    5448 
    5549BUGS            No bugs known 
  • trunk/MERGE/Makefile

    r6566 r6588  
    224224 
    225225MG_preserves.o: merge.hxx 
     226MG_preserves.o: MG_adapt_ali.hxx 
    226227MG_preserves.o: mg_merge.hxx 
    227228MG_preserves.o: $(ARBHOME)/INCLUDE/ad_k_prot.h 
  • trunk/WINDOW/AW_global_awars.cxx

    r6385 r6588  
    103103} 
    104104 
     105#if defined(DARWIN) 
     106#define OPENURL "open"     
     107#else 
     108#define OPENURL "xdg-open" 
     109#endif // DARWIN 
     110 
    105111GB_ERROR ARB_init_global_awars(AW_root *aw_root, AW_default aw_def, GBDATA *gb_main) { 
    106112    aw_assert(!initialized);                        // don't call twice! 
     
    110116    gb_main4awar = gb_main; 
    111117 
    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(); 
    113119 
    114120    if (!error) { 
  • trunk/WINDOW/aw_global_awars.hxx

    r5675 r6588  
    1616#define AW_GLOBAL_AWARS_HXX 
    1717 
    18 #define AWAR_WWW_BROWSER "www/browser" // how to call the users browser 
     18#define AWAR_WWW_BROWSER "www/browse_cmd" // how to call the users browser 
    1919 
    2020#else