Commit 8604544f authored by Ivanq's avatar Ivanq

Merge branch 'commitaddr'

parents fe33f367 e32ff1aa
......@@ -32,6 +32,9 @@
<a href="../support/">
<div class="header-item">Support</div>
</a>
<a href="../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="middle">
<h1>Default Git Center Repo</h1>
......
......@@ -30,6 +30,9 @@
<a href="support/">
<div class="header-item">Support</div>
</a>
<a href="profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="content">
<h1>Welcome to Git Center!</h1>
......
......@@ -31,6 +31,9 @@
<a href="../support/">
<div class="header-item">Support</div>
</a>
<a href="../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="content">
......
......@@ -31,6 +31,9 @@
<a href="../support/">
<div class="header-item">Support</div>
</a>
<a href="../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="content">
<h1>Install a repository</h1>
......
......@@ -891,7 +891,7 @@ class Git {
}
};
Git.init = (root, zeroPage) => {
Git.init = (root, zeroPage, name, email) => {
let zeroFS = new ZeroFS(zeroPage);
let git;
......@@ -912,7 +912,7 @@ Git.init = (root, zeroPage) => {
let minutes = Math.abs((tz + 60) % 60);
tz = (tz > 0 ? "+" : "-") + (hours < 10 ? "0" : "") + hours + (minutes < 10 ? "0" : "") + minutes;
let author = "Git Center <[email protected]> " + Math.floor(+date / 1000) + " " + tz;
let author = name + " <" + email + "> " + Math.floor(+date / 1000) + " " + tz;
return git.writeCommit({
tree: [],
......
......@@ -120,14 +120,16 @@ class Repository {
.then(() => this.sign());
}
install(title, description, address) {
let content;
let auth, content;
return this.getContent()
.then(c => {
content = c;
return this.zeroAuth.requestAuth();
})
.then(auth => {
.then(a => {
auth = a;
content.title = title;
content.description = description;
content.signers = [auth.address];
......@@ -136,7 +138,15 @@ class Repository {
return this.setContent(content);
})
.then(() => {
return Git.init("merged-GitCenter/" + this.address + "/" + address + (address.endsWith(".git") ? "" : ".git"), this.zeroPage);
return this.zeroFS.readFile("data/users/" + auth.address + "/data.json");
})
.then(profile => {
profile = JSON.parse(profile);
profile.commitName = profile.commitName || auth.user[0].toUpperCase() + auth.user.substr(1).replace(/@.*/, "");
profile.commitEmail = profile.commitEmail || auth.user;
return Git.init("merged-GitCenter/" + this.address + "/" + address + (address.endsWith(".git") ? "" : ".git"), this.zeroPage, profile.commitName, profile.commitEmail);
})
.then(git => {
this.git = git;
......@@ -205,17 +215,24 @@ class Repository {
});
}
saveFile(path, content, base, message) {
let author, commit, parent;
let auth, author, commit, parent;
return this.zeroAuth.requestAuth()
.then(auth => {
.then(a => {
auth = a;
return this.zeroFS.readFile("data/users/" + auth.address + "/data.json");
})
.then(profile => {
profile = JSON.parse(profile);
let date = new Date;
let tz = date.getTimezoneOffset() * -1;
let hours = Math.floor(Math.abs(tz / 60));
let minutes = Math.abs((tz + 60) % 60);
tz = (tz > 0 ? "+" : "-") + (hours < 10 ? "0" : "") + hours + (minutes < 10 ? "0" : "") + minutes;
author = auth.user[0].toUpperCase() + auth.user.substr(1).replace(/@.*/, "");
author += " <" + auth.user + ">";
author = profile.commitName || auth.user[0].toUpperCase() + auth.user.substr(1).replace(/@.*/, "");
author += " <" + (profile.commitEmail || auth.user) + ">";
author += " " + Math.floor(+date / 1000);
author += " " + tz;
......
......@@ -31,6 +31,9 @@
<a href="../support/">
<div class="header-item">Support</div>
</a>
<a href="../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="content">
......
.profile {
display: none;
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Install a repository - 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="../repo/settings/css/settings.css">
<link rel="stylesheet" type="text/css" href="css/profile.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="../myrepos/">
<div class="header-item">My Repos</div>
</a>
<a href="../workflow/">
<div class="header-item">Git Center workflow</div>
</a>
<a href="../support/">
<div class="header-item">Support</div>
</a>
<a href="../profile/">
<div class="header-item header-item-active">Profile</div>
</a>
</header>
<main class="content">
<h1>Profile</h1>
</main>
<div id="profile" class="profile">
<div class="entry">
<div class="entry-title">
Commit email
<img src="../img/info.svg" height="16" title="This email is used when committing files via Git Center">
</div>
<div class="entry-value">
<input type="text" class="input" id="commit_email" placeholder="[email protected]">
</div>
</div>
<div class="entry">
<div class="entry-title">
Commit name
</div>
<div class="entry-value">
<input type="text" class="input" id="commit_name" placeholder="Me the Developer">
</div>
</div>
<main class="content">
<a class="button button-blue" id="save">Save</a>
</main>
</div>
<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/ZeroAuth.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 zeroAuth = new ZeroAuth(zeroPage);
let loadProfile = address => {
return zeroFS.readFile("data/users/" + address + "/data.json")
.then(profile => JSON.parse(profile), () => ({}));
};
let saveProfile = (address, profile) => {
return zeroFS.writeFile("data/users/" + address + "/data.json", JSON.stringify(profile, null, "\t"))
.then(() => {
return zeroPage.cmd("sitePublish", {inner_path: "data/users/" + address + "/content.json", sign: true});
})
.then(res => {
if(res != "ok" && res.error != "Port not opened." && res.error != "Content publish failed.") {
return Promise.reject(res);
}
});
};
let auth;
zeroPage.getSiteInfo()
.then(() => {
return zeroAuth.requestAuth();
})
.then(a => {
auth = a;
return loadProfile(auth.address);
})
.then(profile => {
document.getElementById("profile").style.display = "block";
let commitEmail = document.getElementById("commit_email");
commitEmail.value = profile.commitEmail || auth.user;
let commitName = document.getElementById("commit_name");
commitName.value = profile.commitName || auth.user[0].toUpperCase() + auth.user.substr(1).replace(/@.*/, "");
let saveButton = document.getElementById("save");
saveButton.onclick = () => {
if(saveButton.classList.contains("button-disabled")) {
return;
}
saveButton.classList.add("button-disabled");
saveProfile(auth.address, {
commitEmail: commitEmail.value,
commitName: commitName.value
})
.then(() => {
saveButton.classList.remove("button-disabled");
}, e => {
zeroPage.error(e);
saveButton.classList.remove("button-disabled");
});
};
});
\ No newline at end of file
......@@ -34,6 +34,9 @@
<a href="../../support/">
<div class="header-item">Support</div>
</a>
<a href="../../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="middle">
<h1 id="repo_name"></h1>
......
......@@ -34,6 +34,9 @@
<a href="../../support/">
<div class="header-item">Support</div>
</a>
<a href="../../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="middle">
<h1 id="repo_name"></h1>
......
......@@ -32,6 +32,9 @@
<a href="../support/">
<div class="header-item">Support</div>
</a>
<a href="../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="middle">
<h1 id="repo_name"></h1>
......
......@@ -33,6 +33,9 @@
<a href="../../support/">
<div class="header-item">Support</div>
</a>
<a href="../../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="middle">
<h1 id="repo_name"></h1>
......
......@@ -34,6 +34,9 @@
<a href="../../../support/">
<div class="header-item">Support</div>
</a>
<a href="../../../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="middle">
<h1 id="repo_name"></h1>
......
......@@ -34,6 +34,9 @@
<a href="../../../support/">
<div class="header-item">Support</div>
</a>
<a href="../../../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="middle">
<h1 id="repo_name"></h1>
......
......@@ -34,6 +34,9 @@
<a href="../../support/">
<div class="header-item">Support</div>
</a>
<a href="../../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="middle">
<h1 id="repo_name"></h1>
......
......@@ -33,6 +33,9 @@
<a href="../../support/">
<div class="header-item">Support</div>
</a>
<a href="../../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="middle">
<h1 id="repo_name"></h1>
......
......@@ -34,6 +34,9 @@
<a href="../../../support/">
<div class="header-item">Support</div>
</a>
<a href="../../../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="middle">
<h1 id="repo_name"></h1>
......
......@@ -34,6 +34,9 @@
<a href="../../../support/">
<div class="header-item">Support</div>
</a>
<a href="../../../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="middle">
<h1 id="repo_name"></h1>
......
......@@ -33,6 +33,9 @@
<a href="../../support/">
<div class="header-item">Support</div>
</a>
<a href="../../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<main class="middle">
<h1 id="repo_name"></h1>
......
......@@ -31,6 +31,9 @@
<a href=".">
<div class="header-item header-item-active">Support</div>
</a>
<a href="../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<div class="info">
......
......@@ -30,6 +30,9 @@
<a href="../support/">
<div class="header-item">Support</div>
</a>
<a href="../profile/">
<div class="header-item">Profile</div>
</a>
</header>
<div class="info">
......
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