Blob Blame Raw
{% extends "master.html" %}

{% block title %}{{
    repo.namespace + '/' if repo.namespace }}{{ repo.name }}{% endblock %}
{% set tag = "home" %}
{% if g.repo_watch_levels == ['issues', 'commits'] %}
    {% set watch_button_title = 'You are watching issues, PRs, and commits on this project' %}
    {% set watch_button_class = 'btn-primary' %}
{% elif g.repo_watch_levels == ['issues'] %}
    {% set watch_button_title = 'You are watching issues on this project' %}
    {% set watch_button_class = 'btn-info' %}
{% elif g.repo_watch_levels == ['commits'] %}
    {% set watch_button_title = 'You are watching commits on this project' %}
    {% set watch_button_class = 'btn-info' %}
{% else %}
    {% set watch_button_title = 'You are not watching this project' %}
    {% set watch_button_class = 'btn-secondary' %}
{% endif %}

{% block content %}
<div class="repo-header p-t-1">
  <div class="container">
    <header>
      <h2 class="repo-name m-b-0">
        <a href="{{ url_for('view_repo',
            repo=repo.name,
            username=username,
            namespace=repo.namespace)}}">
          {% if repo.private %}
            <span class="oi red-icon" data-glyph="lock-locked"
                  title="Private project"></span>
          {% endif %}
          {% if repo.is_fork -%}
            <span class="oi" data-glyph="fork"></span>
            {{ repo.user.user }}/{{
                repo.namespace + '/' if repo.namespace
            }}{{ repo.name}}
          {%- else -%}
            {{ repo.namespace + '/' if repo.namespace }}{{ repo.name }}
          {%- endif -%}
        </a>
        {% if authenticated %}
        <div class="pull-xs-right">
          {% if repo.settings.get('issue_tracker', True)
                and config.get('ENABLE_TICKETS', True)%}
          <a href="{{ url_for('new_issue',
              repo=repo.name,
              username=username,
              namespace=repo.namespace) }}"
            class="btn btn-success btn-sm">New Issue</a>
          {% endif %}
          <div class="btn-group">
          {% if not repo.is_fork %}
            {% if g.repo_forked %}
              <a href="{{ url_for(
                '.view_repo',
                repo=repo.name,
                username=g.fas_user.username,
                namespace=repo.namespace) }}" class="btn btn-sm btn-secondary">

              <span class="oi" data-glyph="fork"></span> View Fork
              </a>
            {% else %}
            <form method="POST" name="fork_project" id="fork_project"
              action="{{ url_for(
                '.fork_project',
                repo=repo.name,
                username=username,
                namespace=repo.namespace) }}">
              {{ forkbuttonform.csrf_token }}
            </form>
              <button class="btn btn-sm btn-secondary"
              onclick="$('#fork_project').submit();">
              <span class="oi" data-glyph="fork"></span>Fork</button>
            {% endif %}
          {% endif %}
            <button title="{{ watch_button_title }}" type="button"
                    class="btn btn-sm dropdown-toggle {{ watch_button_class }}"
                    data-toggle="dropdown" id="watch-button">
              <span class="oi" data-glyph="eye"></span>
            </button>
            <div class="dropdown-menu dropdown-menu-right watch-menu">
              <form method="POST" id="watch_project" name="watch_project"
                action="{{ url_for('.watch_repo',
                  repo=repo.name,
                  user=repo.user.user if repo.is_fork else None,
                  namespace=repo.namespace,
                  watch=0) }}">
                <a class="dropdown-item" id="watch_issues_button">
                    Watch issues and PRs on "{{ repo.name  }}"
                </a>
                <a class="dropdown-item" id="watch_commits_button">
                    Watch commits on "{{ repo.name }}"
                </a>
                <a class="dropdown-item" id="watch_issues_commits_button">
                    Watch issues, PRs, and commits on "{{ repo.name }}"
                </a>
                <a class="dropdown-item" id="unwatch_button">
                    Unwatch "{{ repo.name }}"
                </a>
                <a class="dropdown-item" id="reset_button">
                    Reset watch status on "{{ repo.name }}"
                </a>
                {{ forkbuttonform.csrf_token }}
              </form>
            </div>
          {% endif %}
        </h2>
        {% if repo.is_fork and repo.parent %}
        <div class="m-t-0">
          Forked from
          <a href="{{ url_for(
            'view_repo',
            repo=repo.parent.name,
            username=repo.parent.user.user if repo.parent.is_fork else None,
            namespace=repo.parent.namespace)}}">
            {{ repo.parent.fullname }}
          </a>
        </div>
        {% elif repo.is_fork and not repo.parent %}
        <div class="m-t-0">
            Fork from a deleted repository
        </div>
        {% endif %}
        <div class="projectinfo m-t-1 m-b-1">
        {% if repo.description %}{{ repo.description | safe }}{% else %}-{% endif -%}
        {%- if repo.url %} &nbsp;| &nbsp;<a class="inline" href="{{ repo.url }}">{{ repo.url }}</a>{% endif %}
        </div>

    </header>
    <ul class="nav nav-tabs nav-small">
      <li class="nav-item">
        <a {%
          if select == 'overview' %}class="nav-link active" {%
          else %}class="nav-link" {%
          endif %}href="{{ url_for(
              'view_repo',
              repo=repo.name,
              username=username,
              namespace=repo.namespace) }}">
            <span class="oi hidden-md-up" data-glyph="home"></span>
            <span class="hidden-sm-down">Overview</span>
        </a>
      </li>
        {% if config['DOC_APP_URL'] and repo and repo.settings.get('project_documentation', True) %}
        <li class="nav-item" >
          <a  {%
            if select == 'docs' %}class="active nav-link" {%
            else %}class="nav-link" {%
            endif %}href="{{ url_for(
                '.view_docs',
                repo=repo.name,
                username=username,
                namespace=repo.namespace) }}">
              <span class="oi hidden-md-up" data-glyph="book"></span>
              <span class="hidden-sm-down">Docs</span>
          </a>
        </li>
        {% endif %}

        <li class="nav-item{%
            if g.repo_obj and g.repo_obj.is_empty %} disabled{% endif %}">
          <a {%
            if select == 'commits' %}class="active nav-link" {%
            else %}class="nav-link" {%
            endif %}href="{{ url_for(
                '.view_commits',
                repo=repo.name,
                username=username,
                namespace=repo.namespace,
                branchname=branchname) }}">
              <span class="oi hidden-md-up" data-glyph="spreadsheet">
              </span><span class="hidden-sm-down">Commits</span>
            </a>
        </li>

        <li class="nav-item{%
            if g.repo_obj and g.repo_obj.is_empty %} disabled{% endif %}">
          <a {%
            if select == 'tree' %}class="active nav-link" {%
            else %}class="nav-link"{%
            endif %} href="{{ url_for(
                '.view_tree',
                repo=repo.name,
                username=username,
                namespace=repo.namespace,
                identifier=branchname) }}">
              <span class="oi hidden-md-up" data-glyph="file"></span>
              <span class="hidden-sm-down">Files</span>
          </a>
        </li>

        <li class="nav-item">
          <a {%
            if select == 'tags' %}class="active nav-link" {%
            else %}class="nav-link" {%
            endif %}href="{{ url_for(
                '.view_tags',
                repo=repo.name,
                username=username,
                namespace=repo.namespace) }}">
              <span class="oi hidden-md-up" data-glyph="box"></span>
              <span class="hidden-sm-down">Releases</span>
          </a>
        </li>

        {% if config.get('ENABLE_TICKETS', True) and repo
              and repo.settings.get('issue_tracker', True) %}
        <li class="nav-item">
            <a {%
              if select == 'issues' %}class="active nav-link" {%
              else %}class="nav-link" {%
              endif %}href="{{ url_for(
                  '.view_issues',
                  repo=repo.name,
                  username=username,
                  namespace=repo.namespace) }}">
                <span class="oi hidden-md-up" data-glyph="warning"></span>
                <span class="hidden-sm-down">Issues&nbsp;</span>
                <span class="label label-default label-pill hidden-sm-down">
                  {{ repo.open_tickets if g.repo_committer else repo.open_tickets_public }}
                </span>
            </a>
        </li>
        {% endif %}

        {% if repo and repo.settings.get('pull_requests', True) %}
        <li class="nav-item">
          <a {%
            if select == 'requests' %}class="active nav-link" {%
            else %}class="nav-link" {%
            endif %}href="{{ url_for(
                '.request_pulls',
                repo=repo.name,
                username=username,
                namespace=repo.namespace) }}">
              <span class="oi hidden-md-up" data-glyph="task"></span>
              <span class="hidden-sm-down">Pull Requests&nbsp;</span>
              <span class="label label-default label-pill hidden-sm-down">
                {{ repo.open_requests }}
              </span>
          </a>
        </li>
        {% endif %}

        {% if repo and repo.forks %}
        <li class="nav-item">
          <a {%
            if select == 'forks' %}class="active nav-link" {%
            else %}class="nav-link" {%
            endif %}href="{{ url_for(
                '.view_forks',
                repo=repo.name,
                username=username,
                namespace=repo.namespace) }}">
              <span class="oi hidden-md-up" data-glyph="fork"></span>
              <span class="hidden-sm-down">Forks&nbsp;</span>
              <span class="hidden-sm-down label label-default label-pill">
                {{ repo.forks |length }}
              </span>
            </a>
        </li>
        {% endif %}

      {% if authenticated %}
        {% if g.repo_admin %}
          <li class="nav-item pull-xs-right">
            <a title="Settings" {%
              if select == 'settings' %}class="active nav-link" {%
              else %}class="nav-link" {%
              endif %}href="{{ url_for(
                  '.view_settings',
                  repo=repo.name,
                  username=username,
                  namespace=repo.namespace) }}">
                <span class="oi" data-glyph="cog"></span>
                <span class="hidden-sm-down">Settings</span>
            </a>
          </li>
        {% endif %}
      {% endif %}
      {% if endpoint == 'view_docs' %}
      <li class="nav-item pull-xs-right">
        <a class="nav-link" href="{{ config['DOC_APP_URL'] + url_for(
            '.view_repo',
            repo=repo.namespace + '.' + repo.name if repo.namespace else repo.name,
            username=username,
            filename=filename)
          }}" target="_blank" title="Open to a new tab" rel="noopener noreferrer">
          <span class="oi" data-glyph="external-link"></span>
        </a>
      </li>
      {% endif %}

    </ul>
  </div>
</div>

<div class="container p-t-3">
{% block repo %}
{% endblock %}
</div>
{% endblock %}

{% block jscripts %}
{{ super() }}
<script type="text/javascript">
$(document).ready(function() {
    {% if g.repo_watch_levels %}
        var currentWatchStatusButton = $('#watch_{{ g.repo_watch_levels | join('_') }}_button');
    {% else %}
        var currentWatchStatusButton = $('#unwatch_button');
    {% endif %}
    currentWatchStatusButton.prepend('<span class="oi" data-glyph="circle-check" style="padding-right:0.5em"></span>');
    $('.watch-menu a').not(currentWatchStatusButton).css('padding-left', '2.85em');

    $(".watch-menu a").click(function(){
        var selectedValue = $(this).attr('id');
        var watchProjectForm = $("#watch_project");
        var action = watchProjectForm.attr('action');

        if (selectedValue === "watch_issues_button") {
            action = action.replace('/settings/0', '/settings/1');
        } else if (selectedValue === "watch_commits_button") {
            action = action.replace('/settings/0', '/settings/2');
        } else if (selectedValue === "watch_issues_commits_button") {
            action = action.replace('/settings/0', '/settings/3');
        } else if (selectedValue === "reset_button") {
            action = action.replace('/settings/0', '/settings/-1');
        }

        watchProjectForm.attr('action', action);
        watchProjectForm.submit();
    });
});
</script>
{% endblock %}