gitlabculture
clone your own copy | download snapshot

Snapshots | iceberg

No images in this repository’s iceberg at this time

Inside this repository

works-commit.html
text/html

Download raw (5.2 KB)

<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">

    <title>OSP works</title>

    <link rel="stylesheet" href="https://semestriel.framapad.org/p/9f7m-osp-website-css/export/txt" type="text/css" media="all" charset="utf-8">

	<style>
        img {
            max-width: 200px;
            max-height: 200px;
        }
	</style>
</head>
<body>

  <div id="menu-wrapper">
    <div class=logo>
    <img id="logo" src="/home/smagnan/Work/osp/osp.cloud/OSP-frog/OSP_frogy-frog.svg"/>
    <span><h1><a>Open Source Publishing</a></h1><h2>applied and performative research in graphic design</h2></span>
  </div>
  <nav class="menu">
    <ul id="menu">
      <li><a>Tools</a></li>
      <li><a>Foundry</a></li>
      <li><a>Workshops</a></li>
      <li><a>Works</a></li>
      <li><a>Researches</a></li>
      <li><a>Live</a></li>
      <li><a>Blog</a></li>
      <li><a>Infos</a></li>
    </ul>
  </nav>
  </div>
  <main>
   <div class="repo">
        <header class="header">
            <h2>work.</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>
    </div>
  </main>

    <script type="text/javascript" charset="utf-8">
        let body = document.querySelector('main');

        var gitlab_url = "http://gitlab.constantvzw.org";
        var user_name = "osp";

        var repos = [508]

        for (i=0; i < repos.length; i++) {
            let header = document.querySelector('header.header'),
                nav = document.querySelector('ul#views'),
                title = document.querySelector('h2.repo-title'),
                repo = document.querySelector('div.repo'),
                commit = document.createElement('div');
            commit.classList.add('latest-commit');
            header.appendChild(title);
            header.append(nav);
            repo.appendChild(commit);
            body.appendChild(repo);
            getMetadata(i, repos[i], repo);
            getLatestCommit(i, repos[i], repo);
        }

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

            fetch(repo_url)
            .then(function(resp){
                //console.log(resp);
                //console.log(resp.json());
                return resp.json();
            })
            .then(function(data){
                let title = repoElt.querySelector('.repo-title');
                name = data.name.split(".").slice(1);
                title.innerHTML = name.replace(",", ".");
            })
        }

        // COMMITS ///////////////////////////////

        function getLatestCommit(i, repoID, repoElt){
            let commits_elt = repoElt.querySelector('.latest-commit');
            let commits_url = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/commits?per_page=1";

            fetch(commits_url)
            .then(function(resp){
                return resp.json();
            })
            .then(function(data){
                return data.map(function(commit) {
                    let li = document.createElement('li'),
                        time = document.createElement('time'),
                        msg = document.createElement('p'),
                        author = document.createElement('p');
                    msg.classList.add("msg");
                    author.classList.add("author");
                    time.innerHTML = commit.created_at;
                    msg.innerHTML = commit.message;
                    author.innerHTML = commit.author_name;
                    li.appendChild(time);
                    li.appendChild(msg);
                    li.appendChild(author);
                    commits_elt.appendChild(li);

                    let commit_id = commit.id;
                    let commit_url = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/commits/" + commit_id + "/diff";
                        fetch(commit_url)
                        .then(function(resp){
                            return resp.json();
                        })
                        .then(function(data2){
                            let filesNb = document.createElement('p');
                            filesNb.classList.add("files-number");
                            filesNb.innerHTML = data2.length + " changed files";
                            li.appendChild(filesNb);
                        })
                    })
                })
                //.catch(function(error) {
                //	console.log(JSON.stringify(error));
                //});
        }
        // END COMMITS

    </script>

    <script type="text/javascript" charset="utf-8" src="generator/static/js/pad.js"> </script>
</body>
</html>