gitlabculture
clone your own copy | download snapshot

Snapshots | iceberg

No images in this repository’s iceberg at this time

Inside this repository

generate.py
text/x-python

Download raw (1.1 KB)

import api
from jinja2 import Environment, FileSystemLoader, select_autoescape
import time
from models import Project

env = Environment(
    loader=FileSystemLoader('templates'),
    autoescape=select_autoescape(['html', 'xml'])
)


def get_projects ():
  call = api.group_projects()
  return call.get()


def get_tree (project_id):
  call = api.tree(project_id)
  return call.get()


def get_commits (project_id):
  call = api.commits(project_id)
  return call.get()


def make_local_url (url):
  return url


def parse_project (project):
  return Project(id=project['id'], tree = get_tree(project['id']), commits = get_commits(project['id']))

print('Loading templates')
projects = [parse_project(project) for project in get_projects()]

print('Starting generation')
template = env.get_template('projects.html')
template.stream(projects=projects).dump('output/index.html') 

project_template = env.get_template('project.html')

for project in projects:
  project_template.stream(project=project).dump('output/{}.html'.format(project.name))

print('Generation finished')

def update_project(project_id):
  call = get_commits(project_id)
  call.invalidate_cache()
  call.get()