예제 #1
0
def index():
    # interpret incoming URL as a tree view, in this format
    #   http://[hostname]/opentree/[{viewer}/]{domSource}@{nodeID}/{taxon name}
    # some valid examples:
    #   http://opentree.com/opentree/argus/ottol@123456/H**o+sapiens
    #   http://opentree.com/opentree/ottol@123456/H**o+sapiens
    #   http://opentree.com/opentree/ottol@123456
    #
    # TODO: add another optional arg 'viewport', like so
    #   http://opentree.com/opentree/argus/0,23,100,400/ottol@123456/H**o+sapiens

    # modify the normal view dictionary to include location+view hints from the URL
    treeview_dict = default_view_dict.copy()
    treeview_dict['viewer'] = 'argus'
    treeview_dict['domSource'] = ''
    treeview_dict['nodeID'] = ''
    treeview_dict['nodeName'] = ''
    treeview_dict['viewport'] = ''

    # add a flag to determine whether to force the viewer to this node (vs. using the
    # browser's stored state for this URL, or a default starting node)
    treeview_dict['forcedByURL'] = False

    # handle the first arg (path part) found
    if len(request.args) > 0:
        if request.args[0] in ['argus', 'onezoom', 'phylet']:
            treeview_dict['viewer'] = request.args[0]
        elif '@' in request.args[0]:
            treeview_dict['domSource'], treeview_dict['nodeID'] = request.args[
                0].split('@')
        else:
            # first arg is neither a viewer nor a proper node, which is a Bad Thing
            raise HTTP(404)

    if len(request.args) > 1:
        if not treeview_dict['nodeID']:
            #if (not treeview_dict['nodeID']) and '@' in request.args[1]:
            treeview_dict['domSource'], treeview_dict['nodeID'] = request.args[
                1].split('@')
        else:
            treeview_dict['nodeName'] = request.args[1]

    if len(request.args) > 2:
        if not treeview_dict['nodeName']:
            treeview_dict['nodeName'] = request.args[2]

    # when all is said and done, do we have enough information to force the location?
    if treeview_dict['domSource'] and treeview_dict['nodeID']:
        treeview_dict['forcedByURL'] = True

    # retrieve latest synthetic-tree ID (and its 'life' node ID)
    # TODO: Only refresh this periodically? Or only when needed for initial destination?
    treeview_dict['draftTreeName'], treeview_dict[
        'startingNodeID'] = fetch_current_synthetic_tree_ids()
    treeview_dict[
        'taxonSearchContextNames'] = fetch_current_TNRS_context_names(request)
    return treeview_dict
예제 #2
0
def index():
    # interpret incoming URL as a tree view, in this format
    #   http://[hostname]/opentree/[{viewer}/]{domSource}@{nodeID}/{taxon name}
    # some valid examples:
    #   http://opentree.com/opentree/argus/ottol@123456/H**o+sapiens
    #   http://opentree.com/opentree/ottol@123456/H**o+sapiens
    #   http://opentree.com/opentree/ottol@123456
    #
    # TODO: add another optional arg 'viewport', like so
    #   http://opentree.com/opentree/argus/0,23,100,400/ottol@123456/H**o+sapiens

    # modify the normal view dictionary to include location+view hints from the URL
    treeview_dict = default_view_dict.copy()
    treeview_dict['viewer'] = 'argus'
    treeview_dict['domSource'] = ''
    treeview_dict['nodeID'] = ''
    treeview_dict['nodeName'] = ''
    treeview_dict['viewport'] = ''

    # add a flag to determine whether to force the viewer to this node (vs. using the
    # browser's stored state for this URL, or a default starting node)
    treeview_dict['forcedByURL'] = False

    # handle the first arg (path part) found
    if len(request.args) > 0:
        if request.args[0] in ['argus','onezoom','phylet']:
            treeview_dict['viewer'] = request.args[0]
        elif '@' in request.args[0]:
            treeview_dict['domSource'], treeview_dict['nodeID'] = request.args[0].split('@')
        else:
            # first arg is neither a viewer nor a proper node, which is a Bad Thing
            raise HTTP(404)

    if len(request.args) > 1:
        if not treeview_dict['nodeID']:
        #if (not treeview_dict['nodeID']) and '@' in request.args[1]:
            treeview_dict['domSource'], treeview_dict['nodeID'] = request.args[1].split('@')
        else:
            treeview_dict['nodeName'] = request.args[1]

    if len(request.args) > 2:
        if not treeview_dict['nodeName']:
            treeview_dict['nodeName'] = request.args[2]

    # when all is said and done, do we have enough information to force the location?
    if treeview_dict['domSource'] and treeview_dict['nodeID']:
        treeview_dict['forcedByURL'] = True

    # retrieve latest synthetic-tree ID (and its 'life' node ID)
    # TODO: Only refresh this periodically? Or only when needed for initial destination?
    treeview_dict['draftTreeName'], treeview_dict['startingNodeID'] = fetch_current_synthetic_tree_ids()
    treeview_dict['taxonSearchContextNames'] = fetch_current_TNRS_context_names(request)
    return treeview_dict
예제 #3
0
def call():
    return service()


### end requires


def index():
    # bump to first About page in menu
    redirect(URL('about', 'open-tree-of-life'))


# try grabbing shared data just once
default_view_dict = get_opentree_services_method_urls(request)
default_view_dict[
    'taxonSearchContextNames'] = fetch_current_TNRS_context_names(request)

# NOTE that web2py should attempt to convert hyphens (dashes) in URLs into underscores


def open_tree_of_life():
    # URL is /opentree/about/open-tree-of-life
    return default_view_dict


def privacy_policy():
    # URL is /opentree/about/privacy-policy
    return default_view_dict


def the_synthetic_tree():
예제 #4
0
# -*- coding: utf-8 -*-
from opentreewebapputil import (get_opentree_services_method_urls, 
                                fetch_current_TNRS_context_names)

### required - do no delete
def user(): return dict(form=auth())
def download(): return response.download(request,db)
def call(): return service()
### end requires

default_view_dict = get_opentree_services_method_urls(request)
default_view_dict['taxonSearchContextNames'] = fetch_current_TNRS_context_names(request)

def index():
    return default_view_dict

예제 #5
0
ot_markdown_attributes.update(common_version_notes_attributes)
ot_cleaner = Cleaner(tags=ot_markdown_tags, attributes=ot_markdown_attributes)

### required - do no delete
def user(): return dict(form=auth())
def download(): return response.download(request,db)
def call(): return service()
### end requires

def index():
    # bump to first About page in menu
    redirect(URL('about', 'open-tree-of-life'))

# try grabbing shared data just once
default_view_dict = get_opentree_services_method_urls(request)
default_view_dict['taxonSearchContextNames'] = fetch_current_TNRS_context_names(request)

# NOTE that web2py should attempt to convert hyphens (dashes) in URLs into underscores

def open_tree_of_life():
    # URL is /opentree/about/open-tree-of-life
    return default_view_dict

def the_synthetic_tree():
    # URL is /opentree/about/the-synthetic-tree
    return default_view_dict

def the_source_tree_manager():
    # URL is /opentree/about/the-source-tree-manager
    return default_view_dict
예제 #6
0
파일: default.py 프로젝트: thyzzs/opentree
def index():
    # interpret incoming URL as a tree view, in this format
    #   http://[hostname]/opentree/[{viewer}/]{domSource}@{nodeID}/{taxon name}
    # some valid examples:
    #   http://opentree.com/opentree/argus/ottol@123456/H**o+sapiens
    #   http://opentree.com/opentree/ottol@123456/H**o+sapiens
    #   http://opentree.com/opentree/ottol@123456
    #
    # TODO: add another optional arg 'viewport', like so
    #   http://opentree.com/opentree/argus/0,23,100,400/ottol@123456/H**o+sapiens

    # modify the normal view dictionary to include location+view hints from the URL
    treeview_dict = default_view_dict.copy()
    treeview_dict['viewer'] = 'argus'
    treeview_dict['domSource'] = ''
    treeview_dict['nodeID'] = ''
    treeview_dict['nodeName'] = ''
    treeview_dict['viewport'] = ''
    treeview_dict['nudgingToLatestSyntheticTree'] = False
    treeview_dict['incomingDomSource'] = 'none'
    treeview_dict['showLegendOnLoad'] = request.vars.get('show-legend') or False

    # add a flag to determine whether to force the viewer to this node (vs. using the
    # browser's stored state for this URL, or a default starting node)
    treeview_dict['forcedByURL'] = False

    # handle the first arg (path part) found
    if len(request.args) > 0:
        if request.args[0] in ['argus', 'feedback', 'properties']:  # TODO: add 'onezoom','phylet', others?
            treeview_dict['viewer'] = request.args[0]
        elif '@' in request.args[0]:
            treeview_dict['domSource'], treeview_dict['nodeID'] = request.args[0].split('@')
        else:
            # first arg is neither a viewer nor a proper node, which is a Bad Thing
            raise HTTP(404)

    if len(request.args) > 1:
        if not treeview_dict['nodeID']:
        #if (not treeview_dict['nodeID']) and '@' in request.args[1]:
            ds_and_node_id = request.args[1].split('@')
            treeview_dict['domSource'] = ds_and_node_id[0]
            if len(ds_and_node_id) > 1:
                treeview_dict['nodeID'] = ds_and_node_id[1]
        else:
            treeview_dict['nodeName'] = request.args[1]

    if len(request.args) > 2:
        if not treeview_dict['nodeName']:
            treeview_dict['nodeName'] = request.args[2]

    # retrieve latest synthetic-tree ID (and its 'life' node ID)
    # TODO: Only refresh this periodically? Or only when needed for initial destination?
    latestSyntheticTreeVersion, startingNodeID = fetch_current_synthetic_tree_ids()
    treeview_dict['draftTreeName'] = latestSyntheticTreeVersion
    treeview_dict['startingNodeID'] = startingNodeID

    # replace any invalid 'domSource' (typically this is "ottol" or a synth-tree version) 
    # with the latest synthetic tree version, and notify the user on the page
    #
    # N.B. that if this is unspecified ('none'), the user requested a shortened
    # URL (e.g. https://tree.opentreeoflife.org/) that resolves to the latest
    # synthetic tree.
    incomingDomSource = treeview_dict.get('domSource', None) or latestSyntheticTreeVersion
    treeview_dict['incomingDomSource'] = incomingDomSource
    if incomingDomSource not in ('ottol', latestSyntheticTreeVersion, ):
        treeview_dict['domSource'] = latestSyntheticTreeVersion
        treeview_dict['nudgingToLatestSyntheticTree'] = True
        # mark this as a redirect to a different resource
        response.status = 303

    # when all is said and done, do we have enough information to force the location?
    if incomingDomSource and treeview_dict['nodeID']:
        treeview_dict['forcedByURL'] = True

    treeview_dict['taxonSearchContextNames'] = fetch_current_TNRS_context_names(request)
    return treeview_dict
예제 #7
0
def index():
    # interpret incoming URL as a tree view, in this format
    #   http://[hostname]/opentree/[{viewer}/]{domSource}@{nodeID}/{taxon name}
    # some valid examples:
    #   http://opentree.com/opentree/argus/ottol@123456/H**o+sapiens
    #   http://opentree.com/opentree/ottol@123456/H**o+sapiens
    #   http://opentree.com/opentree/ottol@123456
    #
    # TODO: add another optional arg 'viewport', like so
    #   http://opentree.com/opentree/argus/0,23,100,400/ottol@123456/H**o+sapiens

    # modify the normal view dictionary to include location+view hints from the URL
    treeview_dict = default_view_dict.copy()
    treeview_dict['viewer'] = 'argus'
    treeview_dict['domSource'] = ''
    treeview_dict['nodeID'] = ''
    treeview_dict['nodeName'] = ''
    treeview_dict['viewport'] = ''
    treeview_dict['nudgingToLatestSyntheticTree'] = False
    treeview_dict['incomingDomSource'] = 'none'

    # add a flag to determine whether to force the viewer to this node (vs. using the
    # browser's stored state for this URL, or a default starting node)
    treeview_dict['forcedByURL'] = False

    # handle the first arg (path part) found
    if len(request.args) > 0:
        if request.args[0] in ['argus',]:  # TODO: add 'onezoom','phylet', others?
            treeview_dict['viewer'] = request.args[0]
        elif '@' in request.args[0]:
            treeview_dict['domSource'], treeview_dict['nodeID'] = request.args[0].split('@')
        else:
            # first arg is neither a viewer nor a proper node, which is a Bad Thing
            raise HTTP(404)

    if len(request.args) > 1:
        if not treeview_dict['nodeID']:
        #if (not treeview_dict['nodeID']) and '@' in request.args[1]:
            treeview_dict['domSource'], treeview_dict['nodeID'] = request.args[1].split('@')
        else:
            treeview_dict['nodeName'] = request.args[1]

    if len(request.args) > 2:
        if not treeview_dict['nodeName']:
            treeview_dict['nodeName'] = request.args[2]

    # retrieve latest synthetic-tree ID (and its 'life' node ID)
    # TODO: Only refresh this periodically? Or only when needed for initial destination?
    latestSyntheticTreeVersion, startingNodeID = fetch_current_synthetic_tree_ids()
    treeview_dict['draftTreeName'] = latestSyntheticTreeVersion
    treeview_dict['startingNodeID'] = startingNodeID

    # replace any invalid 'domSource' (typically this is "ottol" or a synth-tree version) 
    # with the latest synthetic tree version, and notify the user on the page
    #
    # N.B. that if this is unspecified ('none'), the user requested a shortened
    # URL (e.g. https://tree.opentreeoflife.org/) that resolves to the latest
    # synthetic tree.
    incomingDomSource = treeview_dict.get('domSource', None) or latestSyntheticTreeVersion
    treeview_dict['incomingDomSource'] = incomingDomSource
    if incomingDomSource not in ('ottol', latestSyntheticTreeVersion, ):
        treeview_dict['domSource'] = latestSyntheticTreeVersion
        treeview_dict['nudgingToLatestSyntheticTree'] = True
        # mark this as a redirect to a different resource
        response.status = 303

    # when all is said and done, do we have enough information to force the location?
    if incomingDomSource and treeview_dict['nodeID']:
        treeview_dict['forcedByURL'] = True

    treeview_dict['taxonSearchContextNames'] = fetch_current_TNRS_context_names(request)
    return treeview_dict