Commit 9dd7e9c6 authored by Ivanq's avatar Ivanq

Add readme

parent 6886f2a5
......@@ -45,4 +45,17 @@
.new-file {
display: none;
}
/* readme */
.readme {
width: 1006px;
margin: 16px auto;
padding: 8px;
background-color: #DDF;
border: 1px solid #AAF;
border-radius: 4px;
font-size: 16px;
}
\ No newline at end of file
......@@ -98,6 +98,8 @@
<a class="button new-file" id="new_file">New file</a>
</div>
<div class="readme" id="readme"></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>
......@@ -107,6 +109,8 @@
<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="../marked/marked.js"></script>
<script type="text/javascript" src="../hljs/highlight.min.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="js/main.js"></script>
......
......@@ -2,13 +2,21 @@ if(address == "1RepoXU8bQE9m7ssNwL4nnxBnZVejHCc6") {
location.href = "../default/";
}
let head;
let content, head;
marked.setOptions({
highlight: (code, lang) => {
return lang ? hljs.highlight(lang, code).value : hljs.highlightAuto(code).value;
}
});
repo.addMerger()
.then(() => {
return repo.getContent();
})
.then(content => {
.then(c => {
content = c;
if(!content.installed) {
location.href = "../install/?" + address;
}
......@@ -81,4 +89,15 @@ repo.addMerger()
location.href = "?" + address + "/" + parts.join("/").replace(/@/g, "@@") + "@" + branch.replace(/@/g, "@@");
};
}
let readme = files.find(file => file.name.toLowerCase() == "readme" || file.name.toLowerCase() == "readme.md");
if(readme && readme.type == "file") {
return repo.getFile(head, (path ? path + "/" : "") + readme.name)
.then(readme => {
readme = repo.git.arrayToString(readme);
document.getElementById("readme").innerHTML = marked(readme);
});
} else {
document.getElementById("readme").innerHTML = marked("# " + content.title + "\n" + content.description);
}
});
\ 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