Commit 35c83382 authored by Ivanq's avatar Ivanq

Add 'Edit file' page

parent 0b56ebab
.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>
<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">
<header class="header">
<a href="../..">
<img src="../../img/logo-white.svg" class="header-logo">
<div class="header-name">Git Center</div>
<a href="../../index/">
<div class="header-item">Repository Index</div>
<a href="../../myrepos/">
<div class="header-item">My Repos</div>
<a href="../../workflow/">
<div class="header-item">Git Center workflow</div>
<a href="../../support/">
<div class="header-item">Support</div>
<main class="middle">
<h1 id="repo_name"></h1>
<a id="code_link" class="tab tab-current">
<img src="../../img/code.svg" width="16">
<a id="issues_link" class="tab">
<img src="../../img/issue-open.svg" width="16">
<a id="pull_requests_link" class="tab">
<img src="../../img/pr-merged.svg" width="16">
Pull requests
<a id="settings_link" class="tab">
<img src="../../img/settings.svg" width="16">
<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="view">View</a>
<table id="files" class="files">
<tr class="files-header">
<td id="files_path" colspan="2">
<span><a id="files_root">Root</a></span>
<td class="file-content" colspan="2">
<textarea id="file_content" class="file-content-text"></textarea>
<td class="commit-message">
<input type="text" class="input commit-message-input" id="commit_message" placeholder="Commit message">
<td class="commit-node">
<a class="button button-blue commit-button" id="save">Commit</a>
<template id="edit_icon_tmpl">
<img src="../../img/edit.svg" class="edit-icon" id="edit_icon" width="16" height="16">
<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>
\ No newline at end of file
if(address == "1RepoXU8bQE9m7ssNwL4nnxBnZVejHCc6") {
location.href = "../../default/";
.then(() => {
return repo.getContent();
.then(content => {
if(!content.installed) {
location.href = "../../install/?" + address;
document.getElementById("view").href = "../file/?" + address + "/" + path.replace(/@/g, "@@") + "@" + branch.replace(/@/g, "@@");
return repo.getFiles(branch, "");
.then(() => {
// Tree exists
return repo.getFile(branch, path)
.then(blob => {
let fileContent = document.getElementById("file_content");
fileContent.value = repo.git.arrayToString(blob);
let saveButton = document.getElementById("save");
let commitMessage = document.getElementById("commit_message");
saveButton.onclick = () => {
if(saveButton.classList.contains("button-disabled")) {
if(commitMessage.value == "") {
repo.saveFile(path, repo.git.stringToArray(fileContent.value), branch, commitMessage.value)
.then(commit => {
commitMessage.value = "";
}, () => {
// Blob doesn't exist
let fileContent = document.getElementById("file_content");
fileContent.value = "File " + path + " does not exist on branch " + branch;
}, () => {
// Tree doesn't exist
let fileContent = document.getElementById("file_content");
fileContent.textContent = "Unknown branch " + branch;
\ 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