~edwargix/git.sr.ht

b35335119493a2c650c5a5a36f7e3b14963b668e — Drew DeVault 8 years ago 57263a3
Add index page
M gitsrht/blueprints/public.py => gitsrht/blueprints/public.py +11 -0
@@ 1,4 1,5 @@
from flask import Blueprint, Response, request, render_template, abort
from flask_login import current_user
import requests
from srht.config import cfg
from gitsrht.types import User, Repository, RepoVisibility


@@ 8,6 9,16 @@ public = Blueprint('cgit', __name__)
upstream = cfg("cgit", "remote")
meta_uri = cfg("network", "meta")

@public.route("/")
def index():
    if current_user:
        repos = Repository.query.filter(Repository.owner_id == current_user.id)\
                .order_by(Repository.updated.desc())\
                .limit(5).all()
    else:
        repos = None
    return render_template("index.html", repos=repos)

@public.route("/~<user>/<repo>", defaults={ "cgit_path": "" })
@public.route("/~<user>/<repo>/", defaults={ "cgit_path": "" })
@public.route("/~<user>/<repo>/<path:cgit_path>")

A gitsrht/templates/index.html => gitsrht/templates/index.html +56 -0
@@ 0,0 1,56 @@
{% extends "git.html" %}
{% block content %}
<div class="container">
  <div class="row">
    {% if current_user %}
    <div class="col-md-4">
      <h2>git</h2>
      <p>
        Welcome back, {{ current_user.username }}!
      </p>
      <p>
        <a href="/manage">Manage repositories »</a>
      </p>
      <div class="alert alert-danger">
        Notice: this site is a work in progress.
      </div>
    </div>
    <div class="col-md-6">
      {% if repos and len(repos) %}
      <h3>Your repositories</h3>
      {% for repo in repos %}
        <h4>
          <a href="/~{{current_user.username}}/{{repo.name}}">
            ~{{current_user.username}}/{{repo.name}}
          </a>
        </h4>
        {% if repo.description %}
        <p>{{ repo.description }}</p>
        {% endif %}
        <p>
          <em class="text-muted">Last updated {{ repo.updated | date }}</em>
        </p>
      {% endfor %}
      More on <a href="/~{{current_user.username}}">your profile »</a>
      {% endif %}
    </div>
    {% else %}
    <div class="col-md-6">
      <h2>git</h2>
      <p>
        Welcome to git.sr.ht. This is a part of the
        <a href="{{cfg("network", "meta")}}">
          {{cfg("sr.ht", "site-name")}} network
        </a>
        and provides git hosting services to members.
      </p>
      <h3>Features</h3>
      <p>
        Hosts git repos. What more do you want? Also integrates with other
        sr.ht services, none of which actually exist yet.
      </p>
      {% endif %}
    </div>
  </div>
</div>
{% endblock %}

M gitsrht/templates/user.html => gitsrht/templates/user.html +3 -0
@@ 21,6 21,9 @@
      <p>{{profile["bio"]}}</p>
      {% endif %}
      {% endif %}
      {% if current_user %}
        <a href="{{cfg("network", "meta")}}/profile">Edit your profile »</a>
      {% endif %}
    </section>
    <section class="col-md-8">
      {% if len(repos) == 0 %}

M scss/main.scss => scss/main.scss +18 -0
@@ 44,6 44,18 @@ div#cgit {
  div.path {
    background-color: #ddd;
    padding-top: 0;
    
    a {
      padding: 0 0.25rem;

      &:first-child {
        padding-left: 0;
      }

      &:last-child {
        padding-right: 0;
      }
    }
  }

  // Recolor links


@@ 57,6 69,12 @@ div#cgit {
    }
  }

  .highlight {
    .s, .s1, .s2, .si, .se {
      background: transparent;
    }
  }

  pre {
    font-size: 0.8rem;
  }