## -*- coding: utf-8 -*-
<%inherit file="/base/base.html"/>

<%block name="title">
    ${_('Gist')} &middot; ${c.gist.gist_access_id}
</%block>

<%def name="breadcrumbs_links()">
    ${_('Gist')} &middot; ${c.gist.gist_access_id}
    / ${_('URL')}: ${c.gist.gist_url()}
</%def>

<%block name="header_menu">
    ${self.menu('gists')}
</%block>

<%def name="main()">
<div class="panel panel-primary">
    <div class="panel-heading clearfix">
        <div class="pull-left">
            ${self.breadcrumbs()}
        </div>
        %if request.authuser.username != 'default':
        <div class="pull-right">
            <a href="${h.url('new_gist')}" class="btn btn-success btn-sm"><i class="icon-plus"></i>${_('Create New Gist')}</a>
        </div>
        %endif
    </div>
    <div class="panel-body">
        <div id="files_data">
            <div id="body" class="panel panel-default">
                <div class="panel-heading clearfix">
                        <div class="pull-left">
                          %if c.gist.gist_type == 'public':
                            <div class="label label-success">${_('Public Gist')}</div>
                          %else:
                            <div class="label label-warning">${_('Private Gist')}</div>
                          %endif
                        </div>
                        <div class="pull-left">
                            ${c.gist.gist_description}
                        </div>
                        <div class="pull-left text-muted">
                         %if c.gist.gist_expires == -1:
                          ${_('Expires')}: ${_('Never')}
                         %else:
                          ${_('Expires')}: ${h.age(h.time_to_datetime(c.gist.gist_expires))}
                         %endif
                        </div>

                        %if h.HasPermissionAny('hg.admin')() or c.gist.owner_id == request.authuser.user_id:
                        <div class="pull-right">
                            ${h.form(url('gist_delete', gist_id=c.gist.gist_id))}
                                ${h.submit('remove_gist', _('Delete'),class_="btn btn-danger btn-xs",onclick="return confirm('"+_('Confirm to delete this Gist')+"');")}
                            ${h.end_form()}
                        </div>
                        %endif
                        <div class="pull-right">
                          ## only owner should see that
                          %if h.HasPermissionAny('hg.admin')() or c.gist.owner_id == request.authuser.user_id:
                            ${h.link_to(_('Edit'),h.url('edit_gist', gist_id=c.gist.gist_access_id),class_="btn btn-default btn-xs")}
                          %endif
                          ${h.link_to(_('Show as Raw'),h.url('formatted_gist', gist_id=c.gist.gist_access_id, format='raw'),class_="btn btn-default btn-xs")}
                        </div>
                </div>
                <div class="panel-body">
                    <div class="author">
                        ${h.gravatar_div(h.email_or_none(c.file_changeset.author), size=16)}
                        <div title="${c.file_changeset.author}" class="user">${h.person(c.file_changeset.author)} - ${_('created')} ${h.age(c.file_changeset.date)}</div>
                    </div>
                    <div>${h.urlify_text(c.file_changeset.message,c.repo_name)}</div>
                </div>
            </div>

            %for file in c.files:
              <div class="panel panel-default">
                <div id="${h.FID('G', file.path)}" class="panel-heading clearfix">
                    <div class="pull-left">
                      <b>${file.path}</b>
                    </div>
                    <div class="pull-right">
                      ${h.link_to(_('Show as raw'),h.url('formatted_gist_file', gist_id=c.gist.gist_access_id, format='raw', revision=file.changeset.raw_id, f_path=file.path),class_="btn btn-default btn-xs")}
                    </div>
                </div>
                <div class="panel-body no-padding">
                    ${h.pygmentize(file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")}
                </div>
              </div>
            %endfor
        </div>
    </div>

</div>
</%def>
