<commit_before>{#=== OPTIONS ========================================================================================================#}

{% set option = {
    label:  field.label,
    info:   field.info|default('info.upload.video'),
} %}

{#=== INIT ===========================================================================================================#}
{% set randid = random() %}
{% set video = context.content.get(contentkey) %}

{% set videotitle = (video.title is defined) ? '"<b>' ~ video.title|trimtext(18) ~ '</b>" by ' ~ video.authorname|trimtext(18) %}

{% set attributes = {
    url: {
        _bind:        ['video', {key: key}],
        class:        'form-control',
        id:           'video-' ~ key,
        name:         name ~ '[url]',
        placeholder:  __('field.video.placeholder.url') ~ ' …',
        type:         'url',
        value:        video.url|default(''),
        data_video:   'main',
    },

    width: {
        class:      'form-control',
        id:         'video-' ~ key ~ '-width',
        name:       name ~ '[width]',
        type:       'number',
        value:      video.width|default(''),
        data_video: 'width',
    },

    height: {
        class:      'form-control',
        id:         'video-' ~ key ~ '-height',
        name:       name ~ '[height]',
        type:       'number',
        value:      video.height|default(''),
        data_video: 'height',
    },

    hid_ratio: {
        id:         'video-' ~ key ~ '-ratio',
        name:       name ~ '[ratio]',
        type:       'hidden',
        value:      video.ratio|default(''),
        data_video: 'ratio',
    },

    hid_title: {
        id:         'video-' ~ key ~ '-title',
        name:       name ~ '[title]',
        type:       'hidden',
        value:      video.title|default(''),
        data_video: 'title',
    },

    hid_authorname: {
        id:         'video-' ~ key ~ '-author_name',
        name:       name ~ '[authorname]',
        type:       'hidden',
        value:      video.authorname|default(''),
        data_video: 'authorname',
    },

    hid_authorurl: {
        id:         'video-' ~ key ~ '-author_url',
        name:       name ~ '[authorurl]',
        type:       'hidden',
        value:      video.authorurl|default(''),
        data_video: 'authorurl',
    },

    hid_html: {
        id:         'video-' ~ key ~ '-html',
        name:       name ~ '[html]',
        type:       'hidden',
        value:      (video.html is defined ? video.html|replace({'"': '\''}) : ''),
        data_video: 'html',
    },

    hid_thumbnail: {
        id:         'video-' ~ key ~ '-thumbnail',
        name:       name ~ '[thumbnail]',
        type:       'hidden',
        value:      video.thumbnail|default(''),
        data_video: 'thumbnail',
    }
} %}

{#=== FIELDSET =======================================================================================================#}

{% extends '@bolt/_base/_fieldset.twig' %}

{% block fieldset_type 'video' %}

{% block fieldset_label_text  labelkey %}
{% block fieldset_label_info  option.info %}
{% block fieldset_label_class 'col-xs-12' %}

{% block fieldset_controls %}
    <div class="col-sm-8">
        <div class="form-group">
            <div class="col-sm-12">
                <label>{{ __('field.video.label.url') }}</label>
                <input{{ macro.attr(attributes.url) }}>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-sm-2">{{ __('field.video.label.size') }}</label>
            <div class="col-sm-10 form-inline">
                <label for="{{ 'video-' ~ key ~ '-width' }}" class="sr-only">{{ __('field.video.width') }}</label>
                <input{{ macro.attr(attributes.width) }}> ×
                <label for="{{ 'video-' ~ key ~ '-height' }}" class="sr-only">{{ __('field.video.height') }}</label>
                <input{{ macro.attr(attributes.height) }}>
                <label class='label-pixels'>{{ __('field.video.pixel') }}</label>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-9">
                <label>{{ __('field.video.matched-video') }}</label>
                <p id="video-{{ key }}-text">{{ videotitle|raw }}</p>
            </div>

            <div class="hidden-xs col-sm-3">
                <span class="pull-right">
                    <a href="#modal-{{ randid }}" role="button" class="btn btn-default" data-toggle="modal">
                    <i class="fa fa-youtube-play"></i>
                    {{ __('field.video.button.preview') }}</a>
                </span>
            </div>

            <input{{ macro.attr(attributes.hid_ratio) }}>
            <input{{ macro.attr(attributes.hid_title) }}>
            <input{{ macro.attr(attributes.hid_authorname) }}>
            <input{{ macro.attr(attributes.hid_authorurl) }}>
            <input{{ macro.attr(attributes.hid_html) }}>
            <input{{ macro.attr(attributes.hid_thumbnail) }}>
        </div>
    </div>

    <div class="col-sm-4">
        <div class="right-on-large">{# to make the preview align right on wide screens #}
            <label>{{ __('field.video.label.preview') }}</label>
            <div class="imageholder" id="thumbnail-{{ key }}" data-video="thumbcontainer">
                {% if video.thumbnail|default('') %}
                    <img data-video="thumbimage" src="{{ video.thumbnail }}" width="200" height="150">
                {% else %}
                    <img src="{{ app.paths.app }}view/img/default_empty_4x3.png" width="200" height="150"><commit_msg>Alt attribute on video preview<commit_after>{#=== OPTIONS ========================================================================================================#}

{% set option = {
    label:  field.label,
    info:   field.info|default('info.upload.video'),
} %}

{#=== INIT ===========================================================================================================#}
{% set randid = random() %}
{% set video = context.content.get(contentkey) %}

{% set videotitle = (video.title is defined) ? '"<b>' ~ video.title|trimtext(18) ~ '</b>" by ' ~ video.authorname|trimtext(18) %}

{% set attributes = {
    url: {
        _bind:        ['video', {key: key}],
        class:        'form-control',
        id:           'video-' ~ key,
        name:         name ~ '[url]',
        placeholder:  __('field.video.placeholder.url') ~ ' …',
        type:         'url',
        value:        video.url|default(''),
        data_video:   'main',
    },

    width: {
        class:      'form-control',
        id:         'video-' ~ key ~ '-width',
        name:       name ~ '[width]',
        type:       'number',
        value:      video.width|default(''),
        data_video: 'width',
    },

    height: {
        class:      'form-control',
        id:         'video-' ~ key ~ '-height',
        name:       name ~ '[height]',
        type:       'number',
        value:      video.height|default(''),
        data_video: 'height',
    },

    hid_ratio: {
        id:         'video-' ~ key ~ '-ratio',
        name:       name ~ '[ratio]',
        type:       'hidden',
        value:      video.ratio|default(''),
        data_video: 'ratio',
    },

    hid_title: {
        id:         'video-' ~ key ~ '-title',
        name:       name ~ '[title]',
        type:       'hidden',
        value:      video.title|default(''),
        data_video: 'title',
    },

    hid_authorname: {
        id:         'video-' ~ key ~ '-author_name',
        name:       name ~ '[authorname]',
        type:       'hidden',
        value:      video.authorname|default(''),
        data_video: 'authorname',
    },

    hid_authorurl: {
        id:         'video-' ~ key ~ '-author_url',
        name:       name ~ '[authorurl]',
        type:       'hidden',
        value:      video.authorurl|default(''),
        data_video: 'authorurl',
    },

    hid_html: {
        id:         'video-' ~ key ~ '-html',
        name:       name ~ '[html]',
        type:       'hidden',
        value:      (video.html is defined ? video.html|replace({'"': '\''}) : ''),
        data_video: 'html',
    },

    hid_thumbnail: {
        id:         'video-' ~ key ~ '-thumbnail',
        name:       name ~ '[thumbnail]',
        type:       'hidden',
        value:      video.thumbnail|default(''),
        data_video: 'thumbnail',
    }
} %}

{#=== FIELDSET =======================================================================================================#}

{% extends '@bolt/_base/_fieldset.twig' %}

{% block fieldset_type 'video' %}

{% block fieldset_label_text  labelkey %}
{% block fieldset_label_info  option.info %}
{% block fieldset_label_class 'col-xs-12' %}

{% block fieldset_controls %}
    <div class="col-sm-8">
        <div class="form-group">
            <div class="col-sm-12">
                <label>{{ __('field.video.label.url') }}</label>
                <input{{ macro.attr(attributes.url) }}>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-sm-2">{{ __('field.video.label.size') }}</label>
            <div class="col-sm-10 form-inline">
                <label for="{{ 'video-' ~ key ~ '-width' }}" class="sr-only">{{ __('field.video.width') }}</label>
                <input{{ macro.attr(attributes.width) }}> ×
                <label for="{{ 'video-' ~ key ~ '-height' }}" class="sr-only">{{ __('field.video.height') }}</label>
                <input{{ macro.attr(attributes.height) }}>
                <label class='label-pixels'>{{ __('field.video.pixel') }}</label>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-9">
                <label>{{ __('field.video.matched-video') }}</label>
                <p id="video-{{ key }}-text">{{ videotitle|raw }}</p>
            </div>

            <div class="hidden-xs col-sm-3">
                <span class="pull-right">
                    <a href="#modal-{{ randid }}" role="button" class="btn btn-default" data-toggle="modal">
                    <i class="fa fa-youtube-play"></i>
                    {{ __('field.video.button.preview') }}</a>
                </span>
            </div>

            <input{{ macro.attr(attributes.hid_ratio) }}>
            <input{{ macro.attr(attributes.hid_title) }}>
            <input{{ macro.attr(attributes.hid_authorname) }}>
            <input{{ macro.attr(attributes.hid_authorurl) }}>
            <input{{ macro.attr(attributes.hid_html) }}>
            <input{{ macro.attr(attributes.hid_thumbnail) }}>
        </div>
    </div>

    <div class="col-sm-4">
        <div class="right-on-large">{# to make the preview align right on wide screens #}
            <label>{{ __('field.video.label.preview') }}</label>
            <div class="imageholder" id="thumbnail-{{ key }}" data-video="thumbcontainer">
                {% if video.thumbnail|default('') %}
                    <img data-video="thumbimage" src="{{ video.thumbnail }}" width="200" height="150" alt="{{ __('field.video.label.preview') }}">
                {% else %}
                    <img src="{{ app.paths.app }}view/img/default_empty_4x3.png" width="200" height="150" alt="{{ __('No preview image') }}">
{'fraction_non_alphanumeric': 0.2347190417474018, 'fraction_numerical': 0.005108331865421878, 'mean_word_length': 1.9235324407826981, 'pattern_counts': {'":': 0, '<': 111, '<?xml version=': 0, '>': 111, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5206887', 'n_tokens_mistral': 3470, 'n_tokens_neox': 3297, 'n_words': 645}