Пример #1
0
def landing_page(environ,start_response):
    db, dbname, path_components, q = wsgi_response(environ,start_response)
    config = f.WebConfig()
    path = os.getcwd()
    concatenate_files(path, "landing_page", debug=db.locals["debug"])
    return render_template(db=db,dbname=dbname,form=True, q=q, template_name='landing_page.mako',
                           config=config, report="landing_page", ressources=f.concatenate.report_files)
Пример #2
0
def render_time_series(hits, db, dbname, q, path, config):
    concatenate_files(path, "time_series", debug=db.locals["debug"])
    biblio_criteria = f.biblio_criteria(q, config, time_series=True)
    frequencies, date_counts = generate_time_series(q, db, hits)
    return render_template(frequencies=frequencies,db=db,dbname=dbname,q=q,f=f, template_name='time_series.mako',
                           biblio_criteria=biblio_criteria, date_counts=date_counts,
                           config=config, total=len(hits),report="time_series", ressources=f.concatenate.report_files)
Пример #3
0
def render_collocation(hits, db, dbname, q, path, config):
    biblio_criteria = f.biblio_criteria(q, config)
    concatenate_files(path, "collocation", debug=db.locals["debug"])
    all_colloc, left_colloc, right_colloc = fetch_collocation(hits, path, q, db)
    hit_len = len(hits)
    return render_template(all_colloc=all_colloc, left_colloc=left_colloc, right_colloc=right_colloc,
                           db=db,dbname=dbname,q=q,f=f,path=path, results_per_page=q['results_per_page'],
                           hit_len=hit_len, order=sort_to_display,dumps=json.dumps,biblio_criteria=biblio_criteria,
                           config=config, template_name='collocation.mako', report="collocation",
                           ressources=f.concatenate.report_files)
Пример #4
0
def navigation(environ, start_response):
    db, dbname, path_components, q = wsgi_response(environ, start_response)
    path = os.getcwd().replace('functions/', '')
    obj = db[path_components]
    config = f.WebConfig()
    prev = ' '.join(obj.prev.split()[:7])
    next = ' '.join(obj.next.split()[:7])
    current = obj.philo_id[:7]
    if q['format'] == "json":
        if check_philo_virtual(db, path_components):
            obj = db[path_components[:-1]]
        obj_text = f.get_text_obj(obj, path, query_args=q['byte'])
        return json.dumps({
            'current':
            current,
            'text':
            obj_text,
            'prev':
            prev,
            'next':
            next,
            'shrtcit':
            f.cite.make_abs_doc_shrtcit_mobile(db, obj),
            'citation':
            f.cite.make_abs_doc_cite_mobile(db, obj)
        })
    if obj.philo_type == 'doc':
        concatenate_files(path, "t_o_c", debug=db.locals["debug"])
        return render_template(obj=obj,
                               philo_id=obj.philo_id[0],
                               dbname=dbname,
                               f=f,
                               navigate_doc=navigate_doc,
                               db=db,
                               q=q,
                               config=config,
                               template_name='t_o_c.mako',
                               report="t_o_c",
                               ressources=f.concatenate.report_files)
    obj_text = f.get_text_obj(obj, path, query_args=q['byte'])
    concatenate_files(path, "navigation", debug=db.locals["debug"])
    return render_template(obj=obj,
                           philo_id=obj.philo_id[0],
                           dbname=dbname,
                           f=f,
                           navigate_doc=navigate_doc,
                           db=db,
                           q=q,
                           obj_text=obj_text,
                           prev=prev,
                           next=next,
                           config=config,
                           template_name='object.mako',
                           report="navigation",
                           ressources=f.concatenate.report_files)
Пример #5
0
def landing_page(environ, start_response):
    db, dbname, path_components, q = wsgi_response(environ, start_response)
    config = f.WebConfig()
    path = os.getcwd()
    concatenate_files(path, "landing_page", debug=db.locals["debug"])
    return render_template(db=db,
                           dbname=dbname,
                           form=True,
                           q=q,
                           template_name='landing_page.mako',
                           config=config,
                           report="landing_page",
                           ressources=f.concatenate.report_files)
Пример #6
0
def fetch_bibliography(f,path, db, dbname, q, environ):
    if q["no_q"]:
        hits = db.get_all(db.locals['default_object_level'])
    else:
        hits = db.query(**q["metadata"])
    if q['format'] == "json":
        return hits
    else:
        concatenate_files(path, "bibliography", debug=db.locals["debug"])
        config = f.WebConfig()
        biblio_criteria = f.biblio_criteria(q, config)
        return render_template(results=hits,db=db,dbname=dbname,q=q, template_name='bibliography.mako',
                           results_per_page=q['results_per_page'], f=f, biblio_criteria=biblio_criteria,
                           config=config, report="bibliography", ressources=f.concatenate.report_files)
Пример #7
0
def render_concordance(hits, db, dbname, q, path, config):
    concatenate_files(path, "concordance", debug=db.locals["debug"])
    biblio_criteria = f.biblio_criteria(q, config)
    return render_template(results=hits,
                           db=db,
                           dbname=dbname,
                           q=q,
                           fetch_concordance=fetch_concordance,
                           f=f,
                           path=path,
                           results_per_page=q['results_per_page'],
                           biblio_criteria=biblio_criteria,
                           config=config,
                           template_name="concordance.mako",
                           report="concordance",
                           ressources=f.concatenate.report_files)
def concordance_from_collocation(environ,start_response):
    db, dbname, path_components, q = wsgi_response(environ,start_response)
    path = os.getcwd().replace('functions/', '')
    config = f.WebConfig()
    if q['q'] == '':
        return bibliography(f,path, db, dbname,q,environ)
    else:
        hits = db.query(q["q"],q["method"],q["arg"],**q["metadata"])
        colloc_results = fetch_colloc_concordance(hits, path, q, db, config)
        biblio_criteria = []
        for k,v in q["metadata"].iteritems():
            if v:
                if k in config.metadata_aliases:
                    k = config.metadata_aliases[k]
                biblio_criteria.append('<span class="biblio_criteria">%s: <b>%s</b></span>' % (k.title(), v.decode('utf-8', 'ignore'), ))
        biblio_criteria = ' '.join(biblio_criteria)
        concatenate_files(path, "concordance_from_collocation", debug=db.locals["debug"])
        return render_template(results=colloc_results,db=db,dbname=dbname,q=q,colloc_concordance=colloc_concordance,
                               f=f,path=path, results_per_page=q['results_per_page'], config=config,report="concordance_from_collocation",
                               biblio_criteria=biblio_criteria, template_name="concordance_from_collocation.mako",
                               ressources=f.concatenate.report_files)
Пример #9
0
def fetch_bibliography(f, path, db, dbname, q, environ):
    if q["no_q"]:
        hits = db.get_all(db.locals['default_object_level'])
    else:
        hits = db.query(**q["metadata"])
    if q['format'] == "json":
        return hits
    else:
        concatenate_files(path, "bibliography", debug=db.locals["debug"])
        config = f.WebConfig()
        biblio_criteria = f.biblio_criteria(q, config)
        return render_template(results=hits,
                               db=db,
                               dbname=dbname,
                               q=q,
                               template_name='bibliography.mako',
                               results_per_page=q['results_per_page'],
                               f=f,
                               biblio_criteria=biblio_criteria,
                               config=config,
                               report="bibliography",
                               ressources=f.concatenate.report_files)
Пример #10
0
def render_collocation(hits, db, dbname, q, path, config):
    biblio_criteria = f.biblio_criteria(q, config)
    concatenate_files(path, "collocation", debug=db.locals["debug"])
    all_colloc, left_colloc, right_colloc = fetch_collocation(
        hits, path, q, db)
    hit_len = len(hits)
    return render_template(all_colloc=all_colloc,
                           left_colloc=left_colloc,
                           right_colloc=right_colloc,
                           db=db,
                           dbname=dbname,
                           q=q,
                           f=f,
                           path=path,
                           results_per_page=q['results_per_page'],
                           hit_len=hit_len,
                           order=sort_to_display,
                           dumps=json.dumps,
                           biblio_criteria=biblio_criteria,
                           config=config,
                           template_name='collocation.mako',
                           report="collocation",
                           ressources=f.concatenate.report_files)
Пример #11
0
def navigation(environ,start_response):
    db, dbname, path_components, q = wsgi_response(environ,start_response)
    path = os.getcwd().replace('functions/', '')
    obj = db[path_components]
    config = f.WebConfig()
    prev = ' '.join(obj.prev.split()[:7])
    next = ' '.join(obj.next.split()[:7])
    current = obj.philo_id[:7]
    if q['format'] == "json":
        if check_philo_virtual(db, path_components):
            obj = db[path_components[:-1]]
        obj_text = f.get_text_obj(obj, path, query_args=q['byte'])
        return json.dumps({'current': current, 'text': obj_text, 'prev': prev, 'next': next, 'shrtcit':  f.cite.make_abs_doc_shrtcit_mobile(db,obj), 'citation': f.cite.make_abs_doc_cite_mobile(db,obj)})
    if obj.philo_type == 'doc':
        concatenate_files(path, "t_o_c", debug=db.locals["debug"])
        return render_template(obj=obj,philo_id=obj.philo_id[0],dbname=dbname,f=f,navigate_doc=navigate_doc,
                       db=db,q=q,config=config,template_name='t_o_c.mako', report="t_o_c",
                       ressources=f.concatenate.report_files)
    obj_text = f.get_text_obj(obj, path, query_args=q['byte'])
    concatenate_files(path, "navigation", debug=db.locals["debug"])
    return render_template(obj=obj,philo_id=obj.philo_id[0],dbname=dbname,f=f,navigate_doc=navigate_doc,
                       db=db,q=q,obj_text=obj_text,prev=prev,next=next,config=config,
                       template_name='object.mako', report="navigation", ressources=f.concatenate.report_files)
def concordance_from_collocation(environ, start_response):
    db, dbname, path_components, q = wsgi_response(environ, start_response)
    path = os.getcwd().replace('functions/', '')
    config = f.WebConfig()
    if q['q'] == '':
        return bibliography(f, path, db, dbname, q, environ)
    else:
        hits = db.query(q["q"], q["method"], q["arg"], **q["metadata"])
        colloc_results = fetch_colloc_concordance(hits, path, q, db, config)
        biblio_criteria = []
        for k, v in q["metadata"].iteritems():
            if v:
                if k in config.metadata_aliases:
                    k = config.metadata_aliases[k]
                biblio_criteria.append(
                    '<span class="biblio_criteria">%s: <b>%s</b></span>' % (
                        k.title(),
                        v.decode('utf-8', 'ignore'),
                    ))
        biblio_criteria = ' '.join(biblio_criteria)
        concatenate_files(path,
                          "concordance_from_collocation",
                          debug=db.locals["debug"])
        return render_template(
            results=colloc_results,
            db=db,
            dbname=dbname,
            q=q,
            colloc_concordance=colloc_concordance,
            f=f,
            path=path,
            results_per_page=q['results_per_page'],
            config=config,
            report="concordance_from_collocation",
            biblio_criteria=biblio_criteria,
            template_name="concordance_from_collocation.mako",
            ressources=f.concatenate.report_files)
Пример #13
0
def render_concordance(hits, db, dbname, q, path, config):
    concatenate_files(path, "concordance", debug=db.locals["debug"])
    biblio_criteria = f.biblio_criteria(q, config)
    return render_template(results=hits,db=db,dbname=dbname,q=q,fetch_concordance=fetch_concordance,
                               f=f, path=path, results_per_page=q['results_per_page'],biblio_criteria=biblio_criteria,
                               config=config,template_name="concordance.mako", report="concordance", ressources=f.concatenate.report_files)
Пример #14
0
def render_kwic(hits, db, dbname, q, path, config):
    biblio_criteria = f.biblio_criteria(q, config)
    concatenate_files(path, "kwic", debug=db.locals["debug"])
    return render_template(results=hits,db=db,dbname=dbname,q=q,fetch_kwic=fetch_kwic,f=f,
                                path=path, results_per_page=q['results_per_page'], biblio_criteria=biblio_criteria,
                                config=config, template_name='kwic.mako', report="kwic", ressources=f.concatenate.report_files)