def METHOD_NAME(request):
    username = request.matchdict.get('name')
    submitid = request.matchdict.get('submitid')
    rating = define.get_rating(request.userid)
    submitid = define.get_int(submitid) if submitid else define.get_int(request.params.get('submitid'))
    ignore = request.params.get('ignore', '')
    anyway = request.params.get('anyway', '')
    try:
        item = submission.select_view(
            request.userid, submitid, rating,
            ignore=ignore != 'false', anyway=anyway
        )
    except WeasylError as we:
        if we.value in ("UserIgnored", "TagBlocked"):
            we.errorpage_kwargs['links'] = [
                ("View Submission", "?ignore=false"),
                ("Return to the Home Page", "/"),
            ]
        raise
    login = define.get_sysname(item['username'])
    canonical_path = request.route_path('submission_detail_profile', name=login, submitid=submitid, slug=slug_for(item['title']))
    title_with_attribution = f"{item['title']} by {item['username']}"
    twitter_meta = {}
    # The "og:" prefix is specified in page_start.html, and og:image is required by the OGP spec, so something must be in there.
    ogp = {
        'title': title_with_attribution,
        'type': "website",
        'url': define.absolutify_url(canonical_path),
    }
    media_items = item['sub_media']
    cover = media_items.get('cover')
    if cover:
        twitter_meta['card'] = 'summary_large_image'
        twitter_meta['image'] = ogp['image'] = define.absolutify_url(cover[0]['display_url'])
    else:
        twitter_meta['card'] = 'summary'
        thumb = media_items.get('thumbnail-custom') or media_items.get('thumbnail-generated')
        if thumb:
            twitter_meta['image'] = ogp['image'] = define.absolutify_url(thumb[0]['display_url'])
        else:
            ogp['image'] = define.get_resource_url('img/logo-mark-light.svg')
    if twitter_username := profile.get_twitter_username(item['userid']):
        twitter_meta['creator'] = "@" + twitter_username
        twitter_meta['title'] = item['title']
    else:
        twitter_meta['title'] = title_with_attribution
    meta_description = define.summarize(strip_html(item['content']).strip())
    if meta_description:
        twitter_meta['description'] = ogp['description'] = meta_description
    if request.GET.get('anyway'):
        canonical_path += '?anyway=true'
    if login != username:
        raise httpexceptions.HTTPMovedPermanently(location=canonical_path)
    return Response(define.webpage(
        request.userid,
        "detail/submission.html",
        (
            request,
            # Myself
            profile.select_myself(request.userid),
            # Submission detail
            item,
            # Subtypes
            macro.MACRO_SUBCAT_LIST,
            # Violations
            [i for i in macro.MACRO_REPORT_VIOLATION if 2000 <= i[0] < 3000],
        ),
        twitter_card=twitter_meta,
        ogp=ogp,
        canonical_url=canonical_path,
        title=item["title"],
        options=("tags-edit",) if _can_edit_tags(request.userid) else None,
    ))