Ejemplo n.º 1
0
def metadata(recid, of='hd', ot=None):
    """Display formated record metadata."""
    from invenio.legacy.bibrank.downloads_similarity import \
        register_page_view_event
    from invenio.modules.formatter import get_output_format_content_type
    from invenio.modules.formatter.engine import get_output_format, \
        InvenioBibFormatError
    register_page_view_event(recid, current_user.get_id(),
                             str(request.remote_addr))

    try:
        get_output_format(of or request.args.get('of'))
    except InvenioBibFormatError:
        # Needed to prevent propagation to legacy pages.
        return render_template('404.html'), 404

    if get_output_format_content_type(of) != 'text/html':
        from invenio.modules.search.views.search import \
            response_formated_records
        return response_formated_records([recid], g.collection, of, qid=None)

    # Send the signal 'document viewed'
    record_viewed.send(current_app._get_current_object(),
                       recid=recid,
                       id_user=current_user.get_id(),
                       request=request)

    return render_template('records/metadata.html', of=of, ot=ot)
Ejemplo n.º 2
0
def metadata(recid, of='hd'):
    from invenio.legacy.bibrank.downloads_similarity import register_page_view_event
    from invenio.modules.formatter import get_output_format_content_type
    register_page_view_event(recid, current_user.get_id(), str(request.remote_addr))
    if get_output_format_content_type(of) != 'text/html':
        from invenio.modules.search.views.search import response_formated_records
        return response_formated_records([recid], g.collection, of, qid=None)


    # Send the signal 'document viewed'
    record_viewed.send(
        current_app._get_current_object(),
        recid=recid,
        id_user=current_user.get_id(),
        request=request)

    def splitting(value, delimiter='/', maxsplit=0):
        return value.split(delimiter, maxsplit)

    def get_record_name(recid):
        tmp_rec = get_record(recid)
        if tmp_rec is None:
            return 'Can\'t link to record ( WRONG recid )'

        if 'title_additional' in tmp_rec :
            return tmp_rec.get('title_additional', '').get('title', '')
        elif tmp_rec.get('title',{}).get('title',''):
            return tmp_rec.get('title',{}).get('title','')

    def get_record_author_list(recid):
        tmp_rec = get_record(recid)
        if tmp_rec is None:
            return None

        return tmp_rec.get('authors','')


    current_app.jinja_env.filters['splitthem'] = splitting
    current_app.jinja_env.filters['get_record_name'] = get_record_name
    current_app.jinja_env.filters['get_record_author_list'] = get_record_author_list
    current_app.jinja_env.filters['get_download_time'] = calculate_download_time


    record_collection = get_record(recid)['collections'][0]['primary']
    rec_col = Collection.query.filter(Collection.name == record_collection).first_or_404()
    parent_collection = rec_col.most_specific_dad if ( rec_col.most_specific_dad.id != 1 ) else None

    breadcrumbs = [{}]

    if parent_collection:
        breadcrumbs.append({ "url":".collection", "text": parent_collection.name_ln, "param":"name", "value": parent_collection.name })

    breadcrumbs.append({"url":".collection", "text": rec_col.name_ln, "param":"name", "value":rec_col.name })

    try:
        return render_template('records/base_base.html', breadcrumbs = breadcrumbs )
    except TemplateNotFound:
        return abort(404)  # FIX
Ejemplo n.º 3
0
def metadata(recid, of='hd'):
    from invenio.legacy.bibrank.downloads_similarity import register_page_view_event
    from invenio.modules.formatter import get_output_format_content_type
    register_page_view_event(recid, current_user.get_id(), str(request.remote_addr))
    if get_output_format_content_type(of) != 'text/html':
        from invenio.modules.search.views.search import response_formated_records
        return response_formated_records([recid], g.collection, of, qid=None)


    # Send the signal 'document viewed'
    record_viewed.send(
        current_app._get_current_object(),
        recid=recid,
        id_user=current_user.get_id(),
        request=request)


    def get_record_name(recid):
        tmp_rec = get_record(recid)
        if tmp_rec is None:
            return 'Can\'t link to record ( WRONG recid )'

        if 'title_additional' in tmp_rec :
            return tmp_rec.get('title_additional', '').get('title', '')
        elif tmp_rec.get('title',{}).get('title',''):
            return tmp_rec.get('title',{}).get('title','')

    def get_record_author_list(recid):
        tmp_rec = get_record(recid)
        if tmp_rec is None:
            return None

        return tmp_rec.get('authors','')


    current_app.jinja_env.filters['splitthem'] = splitting
    current_app.jinja_env.filters['get_record_name'] = get_record_name
    current_app.jinja_env.filters['get_record_author_list'] = get_record_author_list
    current_app.jinja_env.filters['get_download_time'] = calculate_download_time


    record_collection = get_record(recid)['collections'][0]['primary']
    rec_col = Collection.query.filter(Collection.name == record_collection).first_or_404()
    parent_collection = rec_col.most_specific_dad \
                        if (rec_col.most_specific_dad and \
                            rec_col.most_specific_dad.id != 1) else None

    breadcrumbs = [{}]

    if parent_collection:
        breadcrumbs.append({ "url":".collection", "text": parent_collection.name_ln, "param":"name", "value": parent_collection.name })

    breadcrumbs.append({"url":".collection", "text": rec_col.name_ln, "param":"name", "value":rec_col.name })

    try:
        return render_template(['records/'+record_collection+'_base.html','records/base_base.html'], breadcrumbs = breadcrumbs )
    except TemplateNotFound:
        return abort(404)  # FIX
Ejemplo n.º 4
0
def metadata(recid, of="hd", ot=None):
    """Display formated record metadata."""
    from invenio.legacy.bibrank.downloads_similarity import register_page_view_event
    from invenio.modules.formatter import get_output_format_content_type

    register_page_view_event(recid, current_user.get_id(), str(request.remote_addr))
    if get_output_format_content_type(of) != "text/html":
        from invenio.modules.search.views.search import response_formated_records

        return response_formated_records([recid], g.collection, of, qid=None)

    # Send the signal 'document viewed'
    record_viewed.send(current_app._get_current_object(), recid=recid, id_user=current_user.get_id(), request=request)

    return render_template("records/metadata.html", of=of, ot=ot)
Ejemplo n.º 5
0
def metadata(recid, of='hd', ot=None):
    """Display formated record metadata."""
    from invenio.legacy.bibrank.downloads_similarity import \
        register_page_view_event
    from invenio.modules.formatter import get_output_format_content_type
    register_page_view_event(recid, current_user.get_id(),
                             str(request.remote_addr))
    if get_output_format_content_type(of) != 'text/html':
        from invenio.modules.search.views.search import \
            response_formated_records
        return response_formated_records([recid], g.collection, of, qid=None)

    # Send the signal 'document viewed'
    record_viewed.send(current_app._get_current_object(),
                       recid=recid,
                       id_user=current_user.get_id(),
                       request=request)

    return render_template('records/metadata.html', of=of, ot=ot)