Exemplo n.º 1
0
Arquivo: main.py Projeto: fangang123/h
def annotation_page(annotation, request):
    document = annotation.document
    if document and document.title:
        title = 'Annotation by {user} on {title}'.format(
            user=annotation.userid.replace('acct:', ''),
            title=document.title)
    else:
        title = 'Annotation by {user}'.format(
            user=annotation.userid.replace('acct:', ''))

    alternate = request.route_url('api.annotation', id=annotation.id)

    return render_app(request, {
        'meta_attrs': (
            {'property': 'og:title', 'content': title},
            {'property': 'og:description', 'content': ''},
            {'property': 'og:image', 'content': '/assets/images/logo.png'},
            {'property': 'og:site_name', 'content': 'Hypothes.is'},
            {'property': 'og:url', 'content': request.url},
        ),
        'link_attrs': (
            {'rel': 'alternate', 'href': alternate,
                'type': 'application/json'},
        ),
    })
Exemplo n.º 2
0
def annotation_page(annotation, request):
    document = annotation.document
    if document and document.title:
        title = 'Annotation by {user} on {title}'.format(
            user=annotation.userid.replace('acct:', ''),
            title=document.title)
    else:
        title = 'Annotation by {user}'.format(
            user=annotation.userid.replace('acct:', ''))

    alternate = request.route_url('api.annotation', id=annotation.id)

    return render_app(request, {
        'meta_attrs': (
            {'property': 'og:title', 'content': title},
            {'property': 'og:description', 'content': ''},
            {'property': 'og:image', 'content': '/assets/images/logo.png'},
            {'property': 'og:site_name', 'content': 'Hypothes.is'},
            {'property': 'og:url', 'content': request.url},
        ),
        'link_attrs': (
            {'rel': 'alternate', 'href': alternate,
                'type': 'application/json'},
        ),
    })
Exemplo n.º 3
0
def stream(context, request):
    q = request.params.get('q', '').split(':', 1)
    if len(q) >= 2 and q[0] == 'tag':
        tag = q[1]
        if ' ' in tag:
            tag = '"' + tag + '"'
        query = {'q': 'tag:{}'.format(tag)}
        location = request.route_url('activity.search', _query=query)
        raise httpexceptions.HTTPFound(location=location)
    atom = request.route_url('stream_atom')
    rss = request.route_url('stream_rss')
    return render_app(
        request, {
            'link_tags': [
                {
                    'rel': 'alternate',
                    'href': atom,
                    'type': 'application/atom+xml'
                },
                {
                    'rel': 'alternate',
                    'href': rss,
                    'type': 'application/rss+xml'
                },
            ]
        })
Exemplo n.º 4
0
def stream(context, request):
    atom = request.route_url('stream_atom')
    rss = request.route_url('stream_rss')
    return render_app(request, {
        'link_tags': [
            {'rel': 'alternate', 'href': atom, 'type': 'application/atom+xml'},
            {'rel': 'alternate', 'href': rss, 'type': 'application/rss+xml'},
        ]
    })
Exemplo n.º 5
0
Arquivo: main.py Projeto: fangang123/h
def stream(context, request):
    atom = request.route_url('stream_atom')
    rss = request.route_url('stream_rss')
    return render_app(request, {
        'link_tags': [
            {'rel': 'alternate', 'href': atom, 'type': 'application/atom+xml'},
            {'rel': 'alternate', 'href': rss, 'type': 'application/rss+xml'},
        ]
    })
Exemplo n.º 6
0
Arquivo: main.py Projeto: nlisgo/h
def stream(context, request):
    atom = request.route_url("stream_atom")
    rss = request.route_url("stream_rss")
    return render_app(
        request,
        {
            "link_tags": [
                {"rel": "alternate", "href": atom, "type": "application/atom+xml"},
                {"rel": "alternate", "href": rss, "type": "application/rss+xml"},
            ]
        },
    )
Exemplo n.º 7
0
def stream(context, request):
    q = request.params.get('q', '').split(':', 1)
    if len(q) >= 2 and q[0] == 'tag':
        tag = q[1]
        if ' ' in tag:
            tag = '"' + tag + '"'
        query = {'q': 'tag:{}'.format(tag)}
        location = request.route_url('activity.search', _query=query)
        raise httpexceptions.HTTPFound(location=location)
    atom = request.route_url('stream_atom')
    rss = request.route_url('stream_rss')
    return render_app(request, {
        'link_tags': [
            {'rel': 'alternate', 'href': atom, 'type': 'application/atom+xml'},
            {'rel': 'alternate', 'href': rss, 'type': 'application/rss+xml'},
        ]
    })
Exemplo n.º 8
0
Arquivo: main.py Projeto: nlisgo/h
def annotation_page(annotation, request):
    document = annotation.document
    if document and document.title:
        title = "Annotation by {user} on {title}".format(
            user=annotation.userid.replace("acct:", ""), title=document.title
        )
    else:
        title = "Annotation by {user}".format(user=annotation.userid.replace("acct:", ""))

    alternate = request.route_url("api.annotation", id=annotation.id)

    return render_app(
        request,
        {
            "meta_attrs": (
                {"property": "og:title", "content": title},
                {"property": "og:description", "content": ""},
                {"property": "og:image", "content": "/assets/images/logo.png"},
                {"property": "og:site_name", "content": "Hypothes.is"},
                {"property": "og:url", "content": request.url},
            ),
            "link_attrs": ({"rel": "alternate", "href": alternate, "type": "application/json"},),
        },
    )