Commit d9e15832 authored by Ivanq's avatar Ivanq

Add 'New file' button

parent af9d41c5
......@@ -57,9 +57,10 @@
<div class="info">
<select class="select branches" id="branches"></select>
<a class="info-link" id="permanent_link" title="Link to current tree. Data won't change if branch moves">Permanent link</a>
<a class="info-link button button" id="fork">Fork</a>
<a class="info-link button" id="fork">Fork</a>
<a class="info-link button button-blue" id="publish" title="Use this option after pushing">Sign &amp; Publish changes</a>
<input type="text" class="info-link input" id="git_url">
<a class="info-link button" id="new_file">New file</a>
</div>
<table id="files" class="files">
......
......@@ -17,6 +17,8 @@ repo.addMerger()
showLinks();
showTabs(0);
document.getElementById("new_file").href = "newfile/?" + address + "/" + path.replace(/@/g, "@@") + "@" + branch.replace(/@/g, "@@");
return branch || repo.git.getHead();
})
.then(head => {
......
.files {
table-layout: auto;
width: 1024px;
margin: 0 auto;
border-spacing: 0;
border: 1px solid #DDF;
border-radius: 4px;
}
.files td {
width: auto;
margin: 0;
padding: 8px;
font-size: 16px;
}
.files tr td {
border-top: 1px solid #DDF;
}
.files tr:first-child td {
border-top: none;
}
.files-header {
background-color: #DDF;
font-family: Helvetica, Arial, sans-serif;
}
.files-header a {
color: #008;
}
.file-content, .commit-message {
padding: 0 !important;
}
.file-content-text {
display: block;
width: calc(100% - 16px);
height: 496px;
padding: 8px;
margin: 0;
border: 0;
font-family: Consolas, "Courier New", monospace;
resize: none;
}
.commit-message-input {
display: block;
width: 100%;
margin: 0;
border: 0;
border-radius: 0 0 0 4px;
}
.commit-node {
width: 0 !important;
padding: 0 !important;
border: 0 !important;
}
.commit-button {
border-radius: 0 0 4px 0;
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>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="../../hljs/default.min.css">
<link rel="stylesheet" type="text/css" href="../css/tabs.css">
<link rel="stylesheet" type="text/css" href="../css/info.css">
<link rel="stylesheet" type="text/css" href="css/file.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>
</header>
<main class="middle">
<h1 id="repo_name"></h1>
<a id="code_link" class="tab tab-current">
<img src="../../img/code.svg" width="16">
Code
</a>
<a id="issues_link" class="tab">
<img src="../../img/issue-open.svg" width="16">
Issues
</a>
<a id="pull_requests_link" class="tab">
<img src="../../img/pr-merged.svg" width="16">
Pull requests
</a>
<a id="settings_link" class="tab">
<img src="../../img/settings.svg" width="16">
Settings
</a>
</main>
<div class="info">
<select class="select branches" id="branches"></select>
<a class="info-link" id="permanent_link" title="Link to current tree. Data won't change if branch moves">Permanent link</a>
<a class="info-link button" id="fork">Fork</a>
<a class="info-link button button-blue" id="publish" title="Use this option after pushing">Sign &amp; Publish changes</a>
<input type="text" class="info-link input" id="git_url">
<a class="info-link button" id="cancel">Cancel</a>
</div>
<table id="files" class="files">
<tr class="files-header">
<td colspan="2">
<span id="files_path">
<span><a id="files_root">Root</a></span>
</span>
<input type="text" class="input" placeholder="File name" id="file_name">
</td>
</tr>
<tr>
<td class="file-content" colspan="2">
<textarea id="file_content" class="file-content-text"></textarea>
</td>
</tr>
<tr>
<td class="commit-message">
<input type="text" class="input commit-message-input" id="commit_message" placeholder="Commit message">
</td>
<td class="commit-node">
<a class="button button-blue commit-button" id="save">Commit</a>
</td>
</tr>
</table>
<template id="edit_icon_tmpl">
<img src="../../img/edit.svg" class="edit-icon" id="edit_icon" width="16" height="16">
</template>
<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/pako.js"></script>
<script type="text/javascript" src="../../js/sha.js"></script>
<script type="text/javascript" src="../../js/git.js"></script>
<script type="text/javascript" src="../../js/repo.js"></script>
<script type="text/javascript" src="../js/path_common.js"></script>
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../../hljs/highlight.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html>
\ No newline at end of file
if(address == "1RepoXU8bQE9m7ssNwL4nnxBnZVejHCc6") {
location.href = "../../default/";
}
repo.addMerger()
.then(() => {
return repo.getContent();
})
.then(content => {
if(!content.installed) {
location.href = "../../install/?" + address;
}
showTitle(content.title);
showBranches();
showPath(true);
showLinks();
showTabs(1);
document.getElementById("cancel").href = "../?" + address + "/" + path.replace(/@/g, "@@") + "@" + branch.replace(/@/g, "@@");
let fileContent = document.getElementById("file_content");
let fileName = document.getElementById("file_name");
let saveButton = document.getElementById("save");
let commitMessage = document.getElementById("commit_message");
saveButton.onclick = () => {
if(saveButton.classList.contains("button-disabled")) {
return;
}
if(commitMessage.value == "" || fileName.value == "") {
return;
}
saveButton.classList.add("button-disabled");
repo.saveFile((path ? path + "/" : "") + fileName.value, repo.git.stringToArray(fileContent.value), branch, commitMessage.value)
.then(commit => {
location.href = "../edit/?" + address + "/" + ((path ? path + "/" : "") + fileName.value).replace(/@/g, "@@") + "@" + (repo.git.isSha(branch) ? commit : branch).replace(/@/g, "@@");
});
};
});
\ 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