blob: 8d21f3099b766d5a898e43608ef049399f99533c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
{% extends "main/base.html" %}
{% block title %}Team {{ team.name }}{% endblock %}
{% block og_title %}Team {{ team.name }}{% endblock %}
{% block page_classes %}jam-team-view{% endblock %}
{% block content %}
<div class="uk-section">
<div class="uk-container uk-container-small">
<h1 class="uk-header uk-article-title">
Team <strong>{{ team.name }}</strong>
</h1>
<p class="uk-article-meta">
Code Jam {{ team.jam.number }}
</p>
<p></p>
<div class="uk-grid">
<div class="uk-width-1-2@m">
<h2>
Team Members
</h2>
<div class="participant-card-list">
{% for member in team.members %}
<div class="participant-card uk-card-default">
<img src="{{ member.avatar }}" class="uk-border-circle participant-avatar"
height="20px">
<strong>{{ member.username }}#{{ member.discriminator }}</strong>
<div class="participant-links">
<a href="https://discordapp.com/users/{{ member.user_id }}" target="_blank"
class="uk-button uk-button-default">
<i class="uk-icon fa-fw fab fa-discord"></i>
</a>
<a href="https://gitlab.com/{{ member.gitlab_username }}" target="_blank"
class="uk-button uk-button-default">
<i class="uk-icon fa-fw fab fa-gitlab"></i>
</a>
</div>
</div>
{% endfor %}
</div>
</div>
<div class="uk-width-1-2@m">
<h2>
Activity
</h2>
<p>
<a href="#" class="uk-button uk-button-primary">
<i class="uk-icon fa-fw fab fa-gitlab"></i> View on GitLab
</a>
{% if is_own_team %}
<a href="#" class="uk-button uk-button-default">
<i class="uk-icon fa-fw far fa-pencil"></i>
</a>
{% endif %}
</p>
<div id="gitlab-activity" class="gitlab-activity uk-card-default">
<div id="gitlab-activity-loading" class="gitlab-activity-loading">
<div class="gitlab-activity-loading-content">
<p>
Loading GitLab activity, hang tight...
</p>
<div uk-spinner class="gitlab-activity-spinner"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="application/javascript">
"use strict";
window.onload = () => {
const GITLAB_PROJECT_ID = "python-discord/projects/site"; // the gitlab project id
const GITLAB_EVENT_ACTIONS = ["pushed"]; // the actions to filter in the event list
const JAM_START_DATE = "2018-01-01"; // the start date of the jam, in order to ignore pushes prior to it
const GITLAB_PROJECT_EVENTS_ENDPOINT = `https://gitlab.com/api/v4/projects/${encodeURIComponent(GITLAB_PROJECT_ID)}/events?action=${GITLAB_EVENT_ACTIONS.join(",")}&after=${JAM_START_DATE}`;
function gitlabBranchURL(branch) {
return `https://gitlab.com/${GITLAB_PROJECT_ID}/tree/${branch}`
}
function gitlabCommitURL(commit) {
return `https://gitlab.com/${GITLAB_PROJECT_ID}/commit/${commit}`
}
function onEventsLoaded(events) {
$("#gitlab-activity-loading").remove();
let eventList = $("<div></div>")
.addClass("gitlab-activity-events");
let eventCount = 0;
for (let i = 0; i < events.length; i++) {
let event = events[i];
if (event["push_data"]["action"] !== "pushed") {
continue;
}
let commit = event["push_data"]["commit_to"];
let branch = event["push_data"]["ref"];
let eventDate = Date.parse(event["created_at"]);
let eventElement = $(
""
+ "<div class=\"gitlab-activity-event-item\">"
+ "<div class=\"gitlab-activity-event-item-content\">"
+ `<span><strong>${event["author"]["username"]}</strong> pushed: "${event["push_data"]["commit_title"]}"</span>`
+ "<br>"
+ `<a target=\"blank\" href=\"${gitlabCommitURL(commit)}\" class=\"pasta\">${commit.substring(0, 8)}</a>`
+ `<a target=\"blank\" href=\"${gitlabBranchURL(branch)}\" class=\"pasta\"><i class="uk-icon fa-fw far fa-code-branch"></i> ${branch}</a>`
+ ``
+ "</div>"
+ "</div>"
);
eventList.append(eventElement);
eventCount++;
}
let footerMessage = eventCount > 0 ? "We've reached the end!" : "There is no activity to show at this time.";
// add the footer
let eventListFooter = $(
""
+ "<div class=\"gitlab-activity-events-footer\">"
+ `<span>${footerMessage}</span>`
+ "</div>"
).appendTo(eventList);
$("#gitlab-activity").append(eventList);
}
function onEventsFailed(xhr) {
console.error(xhr);
}
$.get(
GITLAB_PROJECT_EVENTS_ENDPOINT
).done(onEventsLoaded).fail(onEventsFailed);
};
</script>
{% endblock %}
|