project.html 3.74 KB
Newer Older
1
{% extends "base.html" %}
gijs's avatar
gijs committed
2

3
{% block content %}
4
    <div class="repo branch-{{ project.default_branch }}">
5
6
7
8
9
10
11
12
13
14
15
16
        <header class="header">
            <h2 class="repo-title">{{ project.name }}</h2>
            <h2 class="repo-title"></h2>
            <ul id="views">
                <span>views:</span>
              <li><a href="#" id="filter-readme">Description</a></li>
              <li><a href="#" id="filter-commit">Last update</a></li>
              <li><a href="#" id="filter-images">visual process </a></li>
              <li><a href="works-fonts.html" id="filter-fonts">Font used</a></li>
              <li><a href="#" id="filter-tree">Diagram</a></li>
            </ul>
        </header>
sarah's avatar
sarah committed
17
        <section id="repo-content">
18

sarah's avatar
sarah committed
19
		    {% if project.readme %}
sarah's avatar
sarah committed
20
		        <section id="readme" class="repo-views">
sarah's avatar
sarah committed
21
22
23
		        {{ project.readme }}
		        </section>
		    {% endif %}
sarah's avatar
sarah committed
24
		    <section id="tree" class="repo-views">
sarah's avatar
sarah committed
25
26
27
28
29
30
31
			    <h3>Tree</h3>
			    <ul>
			      {% for file in project.tree %}
			        <li>{{ file.name }}</li>
			      {% endfor %}
			    </ul>
		    </section>
sarah's avatar
sarah committed
32
33
		    <section id="iceberg" class="repo-views">
		    	<h3>Iceberg</h3>
34
35
36
                <div v-for="image in repo.iceberg">
                    <img v-bind:src="image.src">
                </div>
sarah's avatar
sarah committed
37
		    </section>
38
39

		    <section id="commits">
sarah's avatar
sarah committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53

			    <h3>Commits</h3>
			    <ul class="commit-list">
			      {% for commit in project.commits %}
			      <li class="commit-item">
			          <a href="https://gitlab.constantvzw.org/osp/{{ project.name }}/-/commit/{{ commit.id }}">
			              <time class="commit-time">{{ commit.committed_date }}</time>
			          </a>
			              <p class="commit-message">{{ commit.message }}</p>
			              <p class="commit-author">{{ commit.author_name }}</p>
			      </li>
			      {% endfor %}
			    </ul>
		    </section>
sarah's avatar
sarah committed
54

sarah's avatar
sarah committed
55
56
57
		    <section id="fonts" class="repo-views">
		    </section>

sarah's avatar
sarah committed
58
    </section>
59
   </div>
60
61
62
{% endblock content %}

{% block script %}
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
    <script type="text/javascript" charset="utf-8">
        var gitlab_url = "http://gitlab.constantvzw.org";
        var user_name = "osp";
        var repoID = {{ project.id }}
        var repo = {}
        

            getMetadata(repoID);
            getIceberg(repoID);

        var reposApp = new Vue({
            el: '#repo',
            data: {
              repo
            }
          })

        // METADATA ///////////////////////////////
        function getMetadata(repoID) {
            let repo_url = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID;

            fetch(repo_url).then(function(resp){ return resp.json(); })
            .then(function(data){
                name = data.name.split(".").slice(1);
                repo.id = repoID;
                repo.repo = data.name;
                repo.name = name.replace(",", " ");
                repo.iceberg = [];

                if (data.default_branch == "archive"){
                    repo.archived = "archived";
                }

            })
        }
        function getIceberg(repoID){
            let icebergURL = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/tree?path=iceberg";

            fetch(icebergURL).then(function(resp){ return resp.json(); })
            .then(function(data){
                return data.map(function(image) {
                    item = {};
                    item.name = image.name;
                    project_path = [gitlab_url, user_name, repo.repo].join('/');
                    if(repo.archived){ branch = "archive";} else { branch = "master" }
                    item.src = project_path + "/raw/" + branch + "/" + image.path;
                    repo.iceberg.push(item);
                })
            });
        }
    </script>

115
{% endblock script %}