[%~ MACRO no_email_warning BLOCK ~%]
    [%~ IF viewing_own_profile && !c.user.has_confirmed_email_address ~%]
        <strong>[% l('Your homepage and biography will not show until you have confirmed your email.') %]</strong>
    [%~ END ~%]
[%~ END ~%]

[%- WRAPPER "user/profile/layout.tt" page="index" %]
    [% BLOCK property %]
        <dt[% IF class %] class="[% class %]"[% END %]>
            [% name %]
        </dt>
        <dd[% IF class %] class="[% class %]"[% END %]>
            [% content %]
        </dd>
    [% END %]

    <h2>[% l('General Information') %]</h2>

    <dl class="profileinfo">
        [% WRAPPER property name=l("Email:") %]
            [% IF user.email %]
                [% IF viewing_own_profile %]
                    [%- html_escape(user.email) %]
                [% ELSE %]
                    [%- l('(hidden)') -%]
                [% END %]

                [% IF user.email_confirmation_date %]
                    [%- l('(verified at {date})', {
                        date  => UserDate.format(user.email_confirmation_date)
                    }) -%]
                [% ELSE %]
                    [%- l('(<strong>unverified!</strong>)') -%] [% no_email_warning() %]
                [% END %]

                [% IF viewing_own_profile %]
                    (<a href="[% c.uri_for('/account/resend-verification') %]">[% l('resend verification email') %]</a>)
                [% END %]

                [% IF c.user_exists AND NOT viewing_own_profile %]
                    (<a href="[% c.uri_for_action('/user/contact', [ user.name ]) %]">[% l("send email") %]</a>)
                [% END %]
            [% ELSE %]
                [% lp('(none)', 'email') %] [% no_email_warning() %]
            [% END %]
        [% END %]

        [% WRAPPER property name=l("User type:") %]
            [% types = [] %]
            [% types.push(l('Deleted User')) IF user.deleted %]
            [% types.push(l('{doc|Auto-Editor}', {doc => doc_link('Auto-Editor')})) IF user.is_auto_editor %]
            [% types.push(l("Internal/Bot")) IF user.is_bot %]
            [% types.push(l('{doc|Relationship Editor}', {doc => doc_link('Relationship_Editor')})) IF user.is_relationship_editor %]
            [% types.push(l('{doc|Transclusion Editor}', {doc => doc_link('Transclusion_Editor')})) IF user.is_wiki_transcluder %]
            [% types.push(l('{doc|Location Editor}', {doc => doc_link('Location_Editor')})) IF user.is_location_editor %]
            [% types.push('<span class="tooltip" title="' _ l('User accounts must be more than 2 weeks old, have a confirmed email address,
                           and more than 10 accepted edits in order to vote on others\' edits.') _ '">' _ l('Limited User') _ '</span>')
                           IF user.is_limited %]
            [% types.push(l('Normal User')) IF types.size == 0 %]
            [% comma_list(types) %]
            [% IF c.user.can_nominate(user) %]
                (<a href="[% c.uri_for_action('/elections/nominate', user.name) %]">[% l("nominate for auto-editor") %]</a>)
            [% END %]
        [% END %]

        [% IF user.age.defined;
             WRAPPER property name=l('Age:');
              user.age;
             END;
           END; %]

        [% IF user.gender;
             WRAPPER property name=l('Gender:');
              user.gender.l_name;
             END;
           END; %]

        [% IF user.area;
             WRAPPER property name=l('Location:');
              descriptive_link(user.area);
             END;
           END; %]

        [% WRAPPER property name=l("Member since:") %]
            [% IF user.name == "rob" %]
                [% l('The Dawn of the Project') %]
            [% ELSIF user.is_charter %]
                [% l('The early days of the project') %]
            [% ELSE %]
                [% UserDate.format(user.registration_date) %]
            [% END %]
        [% END %]

        [% IF user.website && (user.has_confirmed_email_address || c.user.is_account_admin) %]
            [% WRAPPER property name=l("Homepage:") %]
                <a href="[% user.website | url %]" rel="nofollow">
                    [%~ user.website | html_entity ~%]
                </a>
            [% END %]
        [% END %]

        [% WRAPPER property name=l("Subscribers:") %]
            [% IF subscriber_count %]
                [% l('{count} ({url|view list})', { count => subscriber_count, url => c.uri_for_action('/user/subscribers', [ user.name ]) }) %]
            [% ELSE %]
                [% l('0') %]
            [% END %]

            [% IF !viewing_own_profile && c.user_exists %]
                [% IF subscribed %]
                    (<a href="[% c.uri_for_action('/account/subscriptions/editor/remove', { id => user.id }) %]">[% l('unsubscribe') %]</a>)
                [% ELSE %]
                    (<a href="[% c.uri_for_action('/account/subscriptions/editor/add', { id => user.id }) %]">[% l('subscribe') %]</a>)
                [% END %]
            [% END %]

        [% IF user.biography && (user.has_confirmed_email_address || c.user.is_account_admin) %]
            [% WRAPPER property name=l("Bio:") class='biography' %]
                [% user.biography | format_wikitext %]
            [% END %]
        [% END %]

        [% IF user.languages.size %]
          [% WRAPPER property name=l('Languages:') %]
            <ul class="inline">
              [% FOR language=user.languages %]
                <li>[% language.language.l_name %] ([% language.l_fluency %])</li>
              [% END %]
            </ul>
          [% END %]
        [% END %]

        [% END %]
    </dl>

    [% BLOCK statistics %]
        <tr>
            <th>[% name %]</th>
            <td>[% content %]</td>
        </tr>
    [% END %]

    <h2>[% l('Statistics') %]</h2>
    <table class="statistics">
        <thead>
        <tr>
            <th colspan="2">[% l('Edits ({view_url|view})', { view_url => c.uri_for_action('/user/edits/all', [ user.name ]) }) %]</th>
        </tr>
        </thead>

        <tbody>
        [% WRAPPER statistics name=lp("Accepted", 'edit descriptor') %]
            [% l('{count} ({view_url|view})', { count => add_commas(user.accepted_edits), view_url => c.uri_for_action('/user/edits/accepted', [ user.name ]) }) %]
        [% END %]

        [% WRAPPER statistics name=l("Auto-edits") %]
            [% l('{count} ({view_url|view})', { count => add_commas(user.accepted_auto_edits), view_url => c.uri_for_action('/user/edits/autoedits', [ user.name ]) }) %]
        [% END %]

        [% WRAPPER statistics name=l("Voted down") %]
            [% l('{count} ({view_url|view})', { count => add_commas(user.rejected_edits), view_url => c.uri_for_action('/user/edits/rejected', [ user.name ]) }) %]
        [% END %]

        [% WRAPPER statistics name=l("Failed") %]
            [% l('{count} ({view_url|view})', { count => add_commas(user.failed_edits), view_url => c.uri_for_action('/user/edits/failed', [ user.name ]) }) %]
        [% END %]

        [% WRAPPER statistics name=l("Open") %]
            [% l('{count} ({view_url|view})', { count => add_commas(open_count), view_url => c.uri_for_action('/user/edits/open', [ user.name ]) }) %]
        [% END %]

        [% WRAPPER statistics name=l("Cancelled") %]
            [% l('{count} ({view_url|view})', { count => add_commas(cancelled_count), view_url => c.uri_for_action('/user/edits/cancelled', [ user.name ]) }) %]
        [% END %]

        [% WRAPPER statistics name=l("Last 24 hours") %]
            [% l('{count} ({view_url|view})', { count => add_commas(last_day_count),
                     view_url => c.uri_for('/search/edits', {
                         auto_edit_filter => '', order => 'desc',
                         negation => '0', combinator => 'and',
                         'conditions.0.field' => 'editor',
                         'conditions.0.operator' => '=',
                         'conditions.0.name' => user.name,
                         'conditions.0.args.0' => user.id,
                         'conditions.1.field' => 'open_time',
                         'conditions.1.operator' => '>',
                         'conditions.1.args.0' => '24 hours ago'
                     }) }) %]
        [% END %]
        </tbody>
    </table>


    <table class="statistics" title="[% l('This table shows a summary of votes cast by this editor.') %]">
        <thead>
          <tr>
            <th colspan="3">
              [% l('Votes ({view_url|view})', {
                     view_url => c.uri_for_action('/user/edits/votes', [ user.name ])
                 }) %]
            </th>
          </tr>
            <tr>
                <th id="table_vote_summary_vote"></th>
                <th id="table_vote_summary_recent">
                    [% l('Last 28 days') %]
                </th>
                <th id="table_vote_summary_overall">
                    [% l('Overall') %]
                </th>
            </tr>
        </thead>
        <tbody>
            [% FOREACH v IN votes %]
                [% NEXT IF loop.last %]
                <tr>
                    <th headers="table_vote_summary_vote">
                        [% v.name | ucfirst%]
                    </th>
                    <td headers="table_vote_summary_recent">
                        [% add_commas(v.recent.count) %]
                        ([% l('{percentage}%', { percentage => v.recent.percentage }) %])
                    </td>
                    <td headers="table_vote_summary_overall">
                        [% add_commas(v.all.count) %]
                        ([% l('{percentage}%', { percentage => v.all.percentage }) %])
                    </td>
                </tr>
            [% END %]
        </tbody>
        <tfoot>
            [% totals = votes.last %]
                <tr>
                    <th headers="table_vote_summary_vote">
                        [% totals.name | ucfirst%]
                    </th>
                    <th class="totals" headers="table_vote_summary_recent">
                        [% add_commas(totals.recent.count) %]
                        ([% l('100%') %])
                    </th>
                    <th class="totals" headers="table_vote_summary_overall">
                        [% add_commas(totals.all.count) %]
                        ([% l('100%') %])
                    </th>
                </tr>
        </tfoot>
    </table>

[% END %]
