Commit 40384e11 authored by Ivanq's avatar Ivanq

Add 'My repos' page

parent 1391bffe
.repo {
display: block;
margin-top: 16px;
padding: 3px 10px 3px 8px;
border: 1px solid #D5D5D5;
border-radius: 4px;
cursor: pointer;
box-shadow: 0 4px 4px #DDD;
background-image: linear-gradient(to bottom, #FCFCFC 0%, #EEE 100%);
background-repeat: no-repeat;
font-size: 16px;
line-height: 24px;
text-decoration: none;
}
.repo-title {
font-size: 24px;
line-height: 32px;
}
.repo-address {
color: #888;
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Repository Index - Git Center</title>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<base href="" target="_top" id="base">
<script>base.href = document.location.href.replace("/media", "").replace("index.html", "").replace(/[&?]wrapper=False/, "").replace(/[&?]wrapper_nonce=[A-Za-z0-9]+/, "")</script>
<link rel="stylesheet" type="text/css" href="../css/main.css">
<link rel="stylesheet" type="text/css" href="../css/buttons.css">
<link rel="stylesheet" type="text/css" href="../css/header.css">
<link rel="stylesheet" type="text/css" href="../css/content.css">
<link rel="stylesheet" type="text/css" href="css/repo.css">
</head>
<body>
<header class="header">
<a href="..">
<img src="../img/logo-white.svg" class="header-logo">
<div class="header-name">Git Center</div>
</a>
<a href="../index/">
<div class="header-item">Repository Index</div>
</a>
<a href=".">
<div class="header-item header-item-active">My Repos</div>
</a>
</header>
<main class="content">
<h1>My Repos <a id="download_repo" class="button button-blue">Download a new repo</a></h1>
<div id="repos"></div>
</main>
<script type="text/javascript" src="../js/ZeroFrame.js"></script>
<script type="text/javascript" src="../js/ZeroPage.js"></script>
<script type="text/javascript" src="../js/ZeroFS.js"></script>
<script type="text/javascript" src="../js/ZeroDB.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html>
\ No newline at end of file
let zeroFrame = new ZeroFrame();
let zeroPage = new ZeroPage(zeroFrame);
let zeroFS = new ZeroFS(zeroPage);
let zeroDB = new ZeroDB(zeroPage);
zeroPage.cmd("mergerSiteList")
.then(repos => {
repos = Object.keys(repos);
let index = repos.indexOf("1iNDExENNBsfHc6SKmy1HaeasHhm3RPcL");
if(index > -1) {
repos.splice(index, 1);
}
return Promise.all(
repos.map(repo => {
return zeroFS.readFile("merged-GitCenter/" + repo + "/content.json")
.then(content => {
content = JSON.parse(content);
return {
description: content.title + " (" + content.description + ")",
address: repo
};
});
})
);
})
.then(repos => {
repos.forEach(repo => {
let node = document.createElement("a");
node.className = "repo";
node.href = "/" + repo.address;
let title = document.createElement("div");
title.className = "repo-title";
title.textContent = repo.description;
node.appendChild(title);
let address = document.createElement("div");
address.className = "repo-address";
address.textContent = repo.address;
node.appendChild(address);
document.getElementById("repos").appendChild(node);
});
document.getElementById("download_repo").onclick = () => {
let example = location.protocol + "//" + location.host + "/1RepoXU8bQE9m7ssNwL4nnxBnZVejHCc6/";
zeroPage.alert("You can download a new repo by simply visiting its address, like <b>" + example + "</b>");
};
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment