Esempio n. 1
0
def menu():
    # Maps projects to list of experiments
    episode_choices_map =  {}
    for (category,exp) in get_experiment_list():
        episode_url = get_experiment_url(category,exp)
        
        menu = ''
        if len(category)>0: menu = category
        if not menu in episode_choices_map:
            episode_choices_map[menu] = []
        
        episode_choices_map[menu].append((exp, episode_url))
    
    episode_page = '<div class="mega_menu" id="episode-selection">'
    for category in sorted(episode_choices_map.keys()):
        cat_episodes = episode_choices_map[category]
        cat_episodes = sorted(cat_episodes, key=lambda tup: tup[0])
        div_id = category.lower().replace(' ', '-')
        episode_page += '<div class="mega_menu_column" id="'+div_id+'">'
        episode_page += '<h3 class="category-title">'+category.replace('-',' ')+'</h3>'
        episode_page += '<div class="category-episodes">'
        
        technology_episodes = {}
        for (exp,url) in cat_episodes:
            data = experiment_load_queries(category, exp)
            if data is None:
                app.logger.warn("Failed to load episodes for " + str((category, exp)))
                continue
            if "meta" not in data:
                app.logger.warn("Meta data missing for episodes for " + str((category, exp)))
                continue
            meta = data['meta']
            if "name" not in meta or "platforms" not in meta:
                app.logger.warn("Meta data missing for episodes for " + str((category, exp)))
                continue
            
            if not 'published' in meta: meta['published'] = 'true'
            if meta['published'] == 'false': continue
            
            for t in meta['platforms']:
                if t not in technology_episodes.keys(): technology_episodes[t] = []
                technology_episodes[t].append((meta['name'], url))
        
        for t in sorted(technology_episodes.keys()):
            episode_page += '<h4 class="technology-title">'+t+'</h4>'
            for (name,url) in technology_episodes[t]:
                episode_page += '<a href="'+ url +'">'+name+'</a>'
        episode_page += '</div></div>'
    episode_page += '</div>'
    
    menu_left = []
    menu_right = [{
        'text': 'Episode Selection',
        'submenu': [{
            'text': '',
            'submenu_page': episode_page
        }]
    }]
    
    return jsonify(menu_left=menu_left, menu_right=menu_right)
Esempio n. 2
0
def menu():
    # Maps projects to list of experiments
    episode_choices_map = _generate_episode_choices_map_from_experiment_list()

    episode_page = '<div class="mega_menu" id="episode-selection">'
    for category in sorted(episode_choices_map.keys()):
        cat_episodes = episode_choices_map[category]
        cat_episodes = sorted(cat_episodes, key=lambda tup: tup[0])
        div_id = category.lower().replace(' ', '-')
        episode_page += '<div class="mega_menu_column" id="' + div_id + '">'
        episode_page += '<h3 class="category-title">' + category.replace(
            '-', ' ') + '</h3>'
        episode_page += '<div class="category-episodes">'

        technology_episodes = {}
        for (exp, category) in cat_episodes:
            data = experiment_load_queries(category, exp)
            if data is None:
                app.logger.warn("Failed to load episodes for " +
                                str((category, exp)))
                continue
            if "meta" not in data:
                app.logger.warn("Meta data missing for episodes for " +
                                str((category, exp)))
                continue
            meta = data['meta']
            if "name" not in meta or "platforms" not in meta:
                app.logger.warn("Meta data missing for episodes for " +
                                str((category, exp)))
                continue

            if 'published' not in meta:
                meta['published'] = 'true'
            if meta['published'] == 'false':
                continue

            for t in meta['platforms']:
                if t not in technology_episodes.keys():
                    technology_episodes[t] = []
                technology_episodes[t].append((meta['name'], (exp, category)))

        for t in sorted(technology_episodes.keys()):
            episode_page += '<h4 class="technology-title">' + t + '</h4>'
            for (name, (exp, category)) in technology_episodes[t]:
                episode_page += '<a style="cursor: pointer" onclick=client.setEpisode("' + category + '","' + exp + '")>' + name + '</a>'
        episode_page += '</div></div>'
    episode_page += '</div>'

    menu_left = []
    menu_right = [{
        'text': 'Experiment Selection',
        'submenu': [{
            'text': '',
            'submenu_page': episode_page
        }]
    }]

    return jsonify(menu_left=menu_left, menu_right=menu_right)