Added API for git checkout
This commit is contained in:
parent
bdb932cfcb
commit
cf923adb90
1 changed files with 115 additions and 339 deletions
454
configurator.py
454
configurator.py
|
@ -44,7 +44,7 @@ GIT = False
|
|||
### End of options
|
||||
|
||||
RELEASEURL = "https://api.github.com/repos/danielperna84/hass-poc-configurator/releases/latest"
|
||||
VERSION = "0.1.3"
|
||||
VERSION = "0.1.2"
|
||||
BASEDIR = "."
|
||||
DEV = False
|
||||
HTTPD = None
|
||||
|
@ -79,20 +79,22 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
|
||||
#editor {
|
||||
position: fixed;
|
||||
top: 135px;
|
||||
top: 155px;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 600px) {
|
||||
#editor {
|
||||
top: 125px;
|
||||
}
|
||||
}
|
||||
top: 145px;
|
||||
bottom: 56px;
|
||||
}
|
||||
|
||||
#edit_float {
|
||||
#edit_float {
|
||||
bottom: 85px;
|
||||
z-index: 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#filebrowser {
|
||||
background-color: #fff;
|
||||
|
@ -102,17 +104,9 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
display: block;
|
||||
cursor: initial;
|
||||
pointer-events: none;
|
||||
color: #616161 !important;
|
||||
font-weight: 400;
|
||||
font-size: .9em;
|
||||
}
|
||||
|
||||
#fbheaderbranch {
|
||||
padding: 2px 18px !important;
|
||||
display: none;
|
||||
line-height: 0.7em;
|
||||
font-weight: 400;
|
||||
font-size: 0.7em;
|
||||
color: rgba(0, 0, 0, 0.54);
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
#fbelements {
|
||||
|
@ -124,18 +118,14 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
color: #616161 !important;
|
||||
}
|
||||
|
||||
.fbtoolbarbutton {
|
||||
color: #757575 !important;
|
||||
}
|
||||
|
||||
.fbmenubutton {
|
||||
color: #616161 !important;
|
||||
color: rgba(0, 0, 0, 0.54) !important;
|
||||
display: inline-block;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.filename {
|
||||
color: #616161 !important;
|
||||
color: rgba(0, 0, 0, 0.54);
|
||||
vertical-align: text-bottom;
|
||||
font-weight: 400;
|
||||
display: inline-block;
|
||||
|
@ -146,72 +136,14 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
cursor: pointer;
|
||||
}
|
||||
|
||||
.nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.text_darkgreen {
|
||||
color: #1b5e20 !important;
|
||||
}
|
||||
|
||||
.text_darkred {
|
||||
color: #b71c1c !important;
|
||||
}
|
||||
|
||||
p.stats {
|
||||
margin: -26px 0 0 40px;
|
||||
padding: 0 16px;
|
||||
font-size: 0.5em;
|
||||
color: #616161 !important;
|
||||
color: rgba(0, 0, 0, 0.54);
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
.collection-item #uplink {
|
||||
background-color: #f5f5f5;
|
||||
width: 320px !important;
|
||||
}
|
||||
|
||||
input.currentfile_input {
|
||||
margin-bottom: -1px;
|
||||
margin-top: 0;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.side_tools {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.fbtoolbarbutton_icon {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.collection {
|
||||
margin: 0;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
li.collection-item {
|
||||
border-bottom: 1px solid #eeeeee !important;
|
||||
}
|
||||
|
||||
.fb_side-nav li {
|
||||
line-height: 36px;
|
||||
}
|
||||
|
||||
.fb_side-nav a {
|
||||
padding: 0 16px;
|
||||
display: inline-block !important;
|
||||
}
|
||||
|
||||
.fb_side-nav li>a>i {
|
||||
margin-right: 16px !important;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.collection .collection-item i.material-icons {
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
|
||||
.green {
|
||||
color: #fff;
|
||||
}
|
||||
|
@ -224,10 +156,6 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
min-width: 180px;
|
||||
}
|
||||
|
||||
#dropdown_gitmenu {
|
||||
min-width: 110px;
|
||||
}
|
||||
|
||||
.dropdown-content li>a,
|
||||
.dropdown-content li>span {
|
||||
color: #616161 !important;
|
||||
|
@ -242,20 +170,43 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
color: #03a9f4 !important;
|
||||
}
|
||||
|
||||
.input-field input[type=text].valid {
|
||||
border-bottom: 1px solid #03a9f4;;
|
||||
box-shadow: 0 1px 0 0 #03a9f4;;
|
||||
}
|
||||
|
||||
.row .input-field input:focus {
|
||||
border-bottom: 1px solid #03a9f4 !important;
|
||||
box-shadow: 0 1px 0 0 #03a9f4 !important
|
||||
}
|
||||
|
||||
.collection {
|
||||
margin: 0;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
li.collection-item {
|
||||
border-bottom: 1px solid #eeeeee !important;
|
||||
}
|
||||
|
||||
.side-nav li {
|
||||
line-height: 36px;
|
||||
}
|
||||
|
||||
.fb_side-nav a {
|
||||
padding: 0 16px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.side-nav li>a>i {
|
||||
margin-right: 16px !important;
|
||||
}
|
||||
|
||||
.collection .collection-item i.material-icons {
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
|
||||
#modal_acekeyboard, #modal_components {
|
||||
top: auto;
|
||||
bottom: -100%;
|
||||
margin: 0;
|
||||
width: 96%;
|
||||
min-height: 96%;
|
||||
min-height: 95%;
|
||||
border-radius: 0;
|
||||
margin: auto;
|
||||
}
|
||||
|
@ -412,6 +363,11 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
background-color: #03a9f4 !important;
|
||||
}
|
||||
|
||||
.collection-item #uplink {
|
||||
background-color: #f5f5f5;
|
||||
width: 320px !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ext-modelist.js" type="text/javascript" charset="utf-8"></script>
|
||||
|
@ -471,17 +427,18 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
<nav class="light-blue">
|
||||
<div class="nav-wrapper">
|
||||
<ul class="left">
|
||||
<li><a class="waves-effect waves-light tooltipped files-collapse hide-on-small-only" data-activates="slide-out" data-position="bottom" data-delay="50" data-tooltip="Browse Filesystem"><i class="material-icons">folder</i></a></li>
|
||||
<li><a class="waves-effect waves-light files-collapse hide-on-med-and-up" data-activates="slide-out"><i class="material-icons">folder</i></a></li>
|
||||
<li><a class="waves-effect waves-light tooltipped files-collapse hide-on-small-only" data-activates="slide-out" data-position="bottom" data-delay="50" data-tooltip="Browse Filesystem"><i class="material-icons">list</i></a></li>
|
||||
<li><a class="waves-effect waves-light files-collapse hide-on-med-and-up" data-activates="slide-out"><i class="material-icons">list</i></a></li>
|
||||
<li><a class="waves-effect waves-light tooltipped hide-on-small-only" data-position="bottom" data-delay="50" data-tooltip="New File" onclick="editor.setValue('');document.getElementById('currentfile').value=document.getElementById('fbheader').innerHTML+separator+'newfile';document.getElementById('currentfile').setSelectionRange(document.getElementById('currentfile').value.length-7, document.getElementById('currentfile').value.length);document.getElementById('currentfile').focus()"><i class="material-icons">note_add</i></a></li>
|
||||
<li><a class="waves-effect waves-light tooltipped hide-on-small-only" data-position="bottom" data-delay="50" data-tooltip="New Folder" href="#modal_newfolder"><i class="material-icons">create_new_folder</i></a></li>
|
||||
</ul>
|
||||
<ul class="right">
|
||||
<li><a class="waves-effect waves-light tooltipped hide-on-small-only" data-position="bottom" data-delay="50" data-tooltip="Save" href="#modal_save"><i class="material-icons">save</i></a></li>
|
||||
<li><a class="waves-effect waves-light tooltipped hide-on-small-only" data-position="bottom" data-delay="50" data-tooltip="Close" href="#modal_close"><i class="material-icons">highlight_off</i></a></li>
|
||||
<!--<li><a class="waves-effect waves-light tooltipped hide-on-small-only" data-position="bottom" data-delay="50" data-tooltip="Delete" href="#modal_delete"><i class="material-icons">delete</i></a></li>-->
|
||||
<li><a class="waves-effect waves-light tooltipped hide-on-small-only" data-position="bottom" data-delay="50" data-tooltip="Search" onclick="editor.execCommand('replace')"><i class="material-icons">search</i></a></li>
|
||||
<li><a class="waves-effect waves-light dropdown-button hide-on-small-only" data-activates="dropdown_menu" data-beloworigin="true"><i class="material-icons right">more_vert</i></a></li>
|
||||
<li><a class="waves-effect waves-light hide-on-med-and-up" href="#modal_save"><i class="material-icons">save</i></a></li>
|
||||
<li><a class="waves-effect waves-light hide-on-med-and-up" href="#modal_close"><i class="material-icons">highlight_off</i></a></li>
|
||||
<li><a class="waves-effect waves-light hide-on-med-and-up" onclick="editor.execCommand('replace')"><i class="material-icons">search</i></a></li>
|
||||
<li><a class="waves-effect waves-light dropdown-button hide-on-small-only" data-activates="dropdown_menu" data-beloworigin="true"><i class="material-icons right">more_vert</i></a></li>
|
||||
<li><a class="waves-effect waves-light dropdown-button hide-on-med-and-up" data-activates="dropdown_menu_mobile" data-beloworigin="true"><i class="material-icons right">more_vert</i></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -489,6 +446,13 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
</div>
|
||||
</header>
|
||||
<main>
|
||||
<ul id="dropdown_tools_mobile" class="dropdown-content z-depth-4">
|
||||
<li><a href="#" onclick="editor.setValue('');document.getElementById('currentfile').value=document.getElementById('fbheader').innerHTML+separator+'newfile';document.getElementById('currentfile').setSelectionRange(document.getElementById('currentfile').value.length-7, document.getElementById('currentfile').value.length);document.getElementById('currentfile').focus()">New File</a></li>
|
||||
<li><a href="#modal_save">Save</a></li>
|
||||
<li><a href="#modal_close">Close</a></li>
|
||||
<!--<li class="divider"></li>
|
||||
<li><a href="#modal_delete">Delete</a></li>-->
|
||||
</ul>
|
||||
<ul id="dropdown_menu" class="dropdown-content z-depth-4">
|
||||
<li><a target="_blank" href="#modal_components">HASS Components</a></li>
|
||||
<li><a href="#" data-activates="ace_settings" class="ace_settings-collapse">Editor Settings</a></li>
|
||||
|
@ -504,12 +468,6 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
<li class="divider"></li>
|
||||
<li><a href="#modal_restart">Restart HASS</a></li>
|
||||
</ul>
|
||||
<ul id="dropdown_gitmenu" class="dropdown-content z-depth-4">
|
||||
<li><a href="#modal_commit" class="nowrap waves-effect">git commit</a></li>
|
||||
</ul>
|
||||
<ul id="dropdown_gitmenu_mobile" class="dropdown-content z-depth-4">
|
||||
<li><a href="#modal_commit" class="nowrap waves-effect">git commit</a></li>
|
||||
</ul>
|
||||
<div id="modal_components" class="modal bottom-sheet modal-fixed-footer">
|
||||
<div class="modal-content_nopad">
|
||||
<iframe src="https://home-assistant.io/components/" style="height: 90vh; width: 100vw"> </iframe>
|
||||
|
@ -1034,37 +992,6 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
</div>
|
||||
<div class="modal-footer"> <a class=" modal-action modal-close waves-effect waves-red btn-flat">No</a> <a onclick="save()" class=" modal-action modal-close waves-effect waves-green btn-flat">Yes</a> </div>
|
||||
</div>
|
||||
<div id="modal_upload" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Upload File</h4>
|
||||
<p>Please choose a file to upload</p>
|
||||
<form action="#" id="uploadform">
|
||||
<div class="file-field input-field">
|
||||
<div class="btn light-blue waves-effect">
|
||||
<span>File</span>
|
||||
<input type="file" id="uploadfile" />
|
||||
</div>
|
||||
<div class="file-path-wrapper">
|
||||
<input class="file-path validate" type="text">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer"> <a class=" modal-action modal-close waves-effect waves-red btn-flat">Cancel</a> <a onclick="upload()" class="modal-action modal-close waves-effect waves-green btn-flat">OK</a> </div>
|
||||
</div>
|
||||
<div id="modal_commit" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>git commit</h4>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="input-field col s12">
|
||||
<input type="text" id="commitmessage">
|
||||
<label class="active" for="commitmessage">Commit message</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer"> <a class=" modal-action modal-close waves-effect waves-red btn-flat">Cancel</a> <a onclick="commit(document.getElementById('commitmessage').value)" class=" modal-action modal-close waves-effect waves-green btn-flat">OK</a> </div>
|
||||
</div>
|
||||
<div id="modal_close" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Close File</h4>
|
||||
|
@ -1079,13 +1006,6 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
</div>
|
||||
<div class="modal-footer"> <a class=" modal-action modal-close waves-effect waves-red btn-flat">No</a> <a onclick="delete_element()" class="modal-action modal-close waves-effect waves-green btn-flat">Yes</a> </div>
|
||||
</div>
|
||||
<div id="modal_gitadd" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>git add</h4>
|
||||
<p>Are you sure you want to add <span class="fb_currentfile"></span> to the index?</p>
|
||||
</div>
|
||||
<div class="modal-footer"> <a class=" modal-action modal-close waves-effect waves-red btn-flat">No</a> <a onclick="gitadd()" class="modal-action modal-close waves-effect waves-green btn-flat">Yes</a> </div>
|
||||
</div>
|
||||
<div id="modal_restart" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Restart</h4>
|
||||
|
@ -1099,26 +1019,13 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
<br>
|
||||
<div class="row">
|
||||
<div class="input-field col s12">
|
||||
<input type="text" id="newfoldername">
|
||||
<input type="text" id="newfoldername" id="newfolder">
|
||||
<label class="active" for="newfoldername">New Folder Name</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer"> <a class=" modal-action modal-close waves-effect waves-red btn-flat">Cancel</a> <a onclick="newfolder(document.getElementById('newfoldername').value)" class=" modal-action modal-close waves-effect waves-green btn-flat">OK</a> </div>
|
||||
</div>
|
||||
<div id="modal_newfile" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>New File</h4>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="input-field col s12">
|
||||
<input type="text" id="newfilename">
|
||||
<label class="active" for="newfilename">New File Name</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer"> <a class=" modal-action modal-close waves-effect waves-red btn-flat">Cancel</a> <a onclick="newfile(document.getElementById('newfilename').value)" class=" modal-action modal-close waves-effect waves-green btn-flat">OK</a> </div>
|
||||
</div>
|
||||
<div id="modal_about" class="modal modal-fixed-footer">
|
||||
<div class="modal-content">
|
||||
<h4><a class="black-text" href="https://github.com/danielperna84/hass-poc-configurator/" target="_blank">HASS Configurator</a></h4>
|
||||
|
@ -1187,32 +1094,19 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
</div>
|
||||
<div class="col s12 m8 l9">
|
||||
<div class="card input-field col s12 grey lighten-4 hoverable">
|
||||
<input class="currentfile_input" value="" id="currentfile" type="text">
|
||||
<input class="grey-text text-darken-3" value="" id="currentfile" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col s12 m8 l9 z-depth-2" id="editor"></div>
|
||||
<div>
|
||||
<div id="slide-out" class="fb_side-nav side-nav grey lighten-4">
|
||||
<div class="side_tools center hide-on-small-only">
|
||||
<a class="col s3 waves-effect fbtoolbarbutton tooltipped grey lighten-4" href="#modal_newfile" data-position="bottom" data-delay="50" data-tooltip="New File"><i class="material-icons fbtoolbarbutton_icon">note_add</i></a>
|
||||
<a class="col s3 waves-effect fbtoolbarbutton tooltipped grey lighten-4" href="#modal_newfolder" data-position="bottom" data-delay="50" data-tooltip="New Folder"><i class="material-icons fbtoolbarbutton_icon">create_new_folder</i></a>
|
||||
<a class="col s3 waves-effect fbtoolbarbutton tooltipped grey lighten-4" href="#modal_upload" data-position="bottom" data-delay="50" data-tooltip="Upload File"><i class="material-icons fbtoolbarbutton_icon">file_upload</i></a>
|
||||
<a class="col s3 waves-effect fbtoolbarbutton tooltipped grey lighten-4 dropdown-button" data-activates="dropdown_gitmenu" data-alignment='right' data-beloworigin='true' data-delay='50' data-position="bottom" data-tooltip="Git"><i class="material-icons fbtoolbarbutton_icon">call_split</i></a>
|
||||
</div>
|
||||
<div class="side_tools center hide-on-med-and-up">
|
||||
<a class="col s3 waves-effect fbtoolbarbutton grey lighten-4" href="#modal_newfile"><i class="material-icons fbtoolbarbutton_icon">note_add</i></a>
|
||||
<a class="col s3 waves-effect fbtoolbarbutton grey lighten-4" href="#modal_newfolder"><i class="material-icons fbtoolbarbutton_icon">create_new_folder</i></a>
|
||||
<a class="col s3 waves-effect fbtoolbarbutton grey lighten-4" href="#modal_upload"><i class="material-icons fbtoolbarbutton_icon">file_upload</i></a>
|
||||
<a class="col s3 waves-effect fbtoolbarbutton grey lighten-4 dropdown-button" data-activates="dropdown_gitmenu_mobile" data-alignment='right' data-beloworigin='true'><i class="material-icons fbtoolbarbutton_icon">call_split</i></a>
|
||||
</div>
|
||||
<div id="filebrowser" class="z-depth-1">
|
||||
<div class="col s12 m8 l9 z-depth-2" id="editor"></div>
|
||||
<div>
|
||||
<div id="slide-out" class="fb_side-nav side-nav grey lighten-4">
|
||||
<div class="z-depth-1" id="filebrowser" class="collection with-header">
|
||||
<ul class="collection with-header">
|
||||
<li id="fbheader" class="collection-header"></li>
|
||||
<li id="fbheaderbranch" class="collection-item"></li>
|
||||
</ul>
|
||||
<ul id="fbelements"></ul>
|
||||
</div>
|
||||
<div class="row hide-on-med-and-up">
|
||||
</div>
|
||||
<div class="row hide-on-med-and-up">
|
||||
<br />
|
||||
<div class="input-field col s12">
|
||||
<select onchange="insert(this.value)">
|
||||
|
@ -1584,7 +1478,7 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<!-- <footer class="hide-on-med-and-up">
|
||||
<footer class="hide-on-med-and-up">
|
||||
<div class="shadow grey darken-4 row s12 z-depth-4"></div>
|
||||
<div class="fixed-action-btn toolbar active grey lighten-4" data-origin-bottom="77" data-origin-left="984" data-origin-width="56" data-open="true" style="text-align: center; width: 100%; bottom: 0px; left: 0px; transition: transform 0.2s cubic-bezier(0.55, 0.085, 0.68, 0.53), background-color 0s linear 0.2s; overflow: hidden;">
|
||||
<div class="fab-backdrop grey lighten-4" style=" transform: scale(26.575); "></div>
|
||||
|
@ -1593,9 +1487,10 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
<li class="waves-effect"><a style="opacity: 1;" href="#modal_newfolder"><i class="material-icons grey-text text-darken-2">create_new_folder</i></a></li>
|
||||
<li class="waves-effect"><a style="opacity: 1;" href="#modal_save"><i class="material-icons grey-text text-darken-2">save</i></a></li>
|
||||
<li class="waves-effect"><a style="opacity: 1;" href="#modal_close"><i class="material-icons grey-text text-darken-2">highlight_off</i></a></li>
|
||||
<!--<li class="waves-effect"><a style="opacity: 1;" href="#modal_delete"><i class="material-icons grey-text text-darken-2">delete</i></a></li>-->
|
||||
</ul>
|
||||
</div>
|
||||
</footer> -->
|
||||
</footer>
|
||||
<input type="hidden" id="fb_currentfile" value="" />
|
||||
<!-- Scripts -->
|
||||
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
|
||||
|
@ -1622,7 +1517,7 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
draggable: true
|
||||
});
|
||||
$('.ace_settings-collapse').sideNav({
|
||||
menuWidth: 300, // Default is 300
|
||||
menuWidth: 320, // Default is 300
|
||||
edge: 'right', // Choose the horizontal origin
|
||||
closeOnClick: true, // Closes side-nav on <a> clicks, useful for Angular/Meteor
|
||||
draggable: true // Choose whether you can drag to open on touch screens
|
||||
|
@ -1639,7 +1534,6 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
.fadeOut('slow');
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
<script>
|
||||
var modemapping = new Object();
|
||||
modemapping['c'] = 'ace/mode/c_cpp';
|
||||
|
@ -1776,65 +1670,19 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
var itext = document.createElement('div');
|
||||
itext.innerHTML = itemdata.name;
|
||||
itext.classList.add('filename');
|
||||
|
||||
var hasgitadd = false;
|
||||
if (itemdata.gitstatus) {
|
||||
if (itemdata.gittracked == 'untracked') {
|
||||
itext.classList.add('text_darkred');
|
||||
hasgitadd = true;
|
||||
}
|
||||
else {
|
||||
if(itemdata.gitstatus == 'unstaged') {
|
||||
itext.classList.add('text_darkred');
|
||||
hasgitadd = true;
|
||||
}
|
||||
else if (itemdata.gitstatus == 'staged') {
|
||||
itext.classList.add('text_darkgreen');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item.appendChild(itext);
|
||||
|
||||
var dropdown = document.createElement('ul');
|
||||
dropdown.id = 'fb_dropdown_' + index;
|
||||
dropdown.classList.add('dropdown-content');
|
||||
dropdown.classList.add('z-depth-4');
|
||||
|
||||
// Download button
|
||||
var dd_download = document.createElement('li');
|
||||
var dd_download_a = document.createElement('a');
|
||||
dd_download_a.classList.add('waves-effect');
|
||||
dd_download_a.setAttribute('onclick', "download_file('" + encodeURI(itemdata.fullpath) + "')");
|
||||
dd_download_a.innerHTML = "Download";
|
||||
dd_download.appendChild(dd_download_a);
|
||||
dropdown.appendChild(dd_download);
|
||||
|
||||
// Delete button
|
||||
var dd_delete = document.createElement('li');
|
||||
var dd_delete_a = document.createElement('a');
|
||||
dd_delete_a.classList.add('waves-effect');
|
||||
dd_delete_a.setAttribute('href', "#modal_delete");
|
||||
dd_delete_a.innerHTML = "Delete";
|
||||
dd_delete.appendChild(dd_delete_a);
|
||||
dropdown.appendChild(dd_delete);
|
||||
|
||||
if (itemdata.gitstatus) {
|
||||
var divider = document.createElement('li');
|
||||
divider.classList.add('divider');
|
||||
dropdown.appendChild(divider);
|
||||
if (hasgitadd) {
|
||||
// git add button
|
||||
var dd_gitadd = document.createElement('li');
|
||||
var dd_gitadd_a = document.createElement('a');
|
||||
dd_gitadd_a.classList.add('waves-effect');
|
||||
dd_gitadd_a.setAttribute('href', "#modal_gitadd");
|
||||
dd_gitadd_a.innerHTML = "git add";
|
||||
dd_gitadd.appendChild(dd_gitadd_a);
|
||||
dropdown.appendChild(dd_gitadd);
|
||||
}
|
||||
}
|
||||
|
||||
var menubutton = document.createElement('a');
|
||||
menubutton.classList.add('fbmenubutton');
|
||||
menubutton.classList.add('waves-effect');
|
||||
|
@ -1861,16 +1709,6 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
}
|
||||
var fbheader = document.getElementById('fbheader');
|
||||
fbheader.innerHTML = dirdata.abspath;
|
||||
//console.log(dirdata);
|
||||
var fbheaderbranch = document.getElementById('fbheaderbranch');
|
||||
if (dirdata.activebranch) {
|
||||
fbheaderbranch.innerHTML = dirdata.activebranch;
|
||||
fbheaderbranch.style.display = "list-item";
|
||||
}
|
||||
else {
|
||||
fbheaderbranch.innerHTML = "";
|
||||
fbheaderbranch.style.display = "";
|
||||
}
|
||||
var upli = document.createElement('li');
|
||||
var up = document.createElement('a');
|
||||
upli.classList.add('collection-item');
|
||||
|
@ -1933,7 +1771,7 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
data.text = editor.getValue()
|
||||
$.post("api/save", data).done(function(resp) {
|
||||
if (resp.error) {
|
||||
var $toastContent = $("<div><pre>" + resp.message + "\n" + resp.path + "</pre></div>");
|
||||
var $toastContent = $("<div><pre>" + resp.message + "\\n" + resp.path + "</pre></div>");
|
||||
Materialize.toast($toastContent, 5000);
|
||||
}
|
||||
else {
|
||||
|
@ -1945,12 +1783,8 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
}
|
||||
}
|
||||
|
||||
function download_file(filepath) {
|
||||
window.open("/api/download?filename="+encodeURI(filepath));
|
||||
}
|
||||
|
||||
function delete_file() {
|
||||
var path = document.getElementById('currentfile').value;
|
||||
var path= document.getElementById('currentfile').value;
|
||||
if (path.length > 0) {
|
||||
data = new Object();
|
||||
data.path= path;
|
||||
|
@ -1963,8 +1797,7 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
var $toastContent = $("<div><pre>" + resp.message + "</pre></div>");
|
||||
Materialize.toast($toastContent, 2000);
|
||||
listdir(document.getElementById('fbheader').innerHTML)
|
||||
document.getElementById('currentfile').value='';
|
||||
editor.setValue('');
|
||||
document.getElementById('currentfile').value='';editor.setValue('');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1983,51 +1816,8 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
else {
|
||||
var $toastContent = $("<div><pre>" + resp.message + "</pre></div>");
|
||||
Materialize.toast($toastContent, 2000);
|
||||
listdir(document.getElementById('fbheader').innerHTML);
|
||||
if (document.getElementById('currentfile').value == path) {
|
||||
document.getElementById('currentfile').value='';
|
||||
editor.setValue('');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function gitadd() {
|
||||
var path = document.getElementById('fb_currentfile').value;
|
||||
if (path.length > 0) {
|
||||
data = new Object();
|
||||
data.path = path;
|
||||
$.post("api/gitadd", data).done(function(resp) {
|
||||
if (resp.error) {
|
||||
var $toastContent = $("<div><pre>" + resp.message + "\n" + resp.path + "</pre></div>");
|
||||
Materialize.toast($toastContent, 5000);
|
||||
}
|
||||
else {
|
||||
var $toastContent = $("<div><pre>" + resp.message + "</pre></div>");
|
||||
Materialize.toast($toastContent, 2000);
|
||||
listdir(document.getElementById('fbheader').innerHTML);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function commit(message) {
|
||||
var path = document.getElementById("fbheader").innerHTML;
|
||||
if (path.length > 0) {
|
||||
data = new Object();
|
||||
data.path = path;
|
||||
data.message = message
|
||||
$.post("api/commit", data).done(function(resp) {
|
||||
if (resp.error) {
|
||||
var $toastContent = $("<div><pre>" + resp.message + "\n" + resp.path + "</pre></div>");
|
||||
Materialize.toast($toastContent, 5000);
|
||||
}
|
||||
else {
|
||||
var $toastContent = $("<div><pre>" + resp.message + "</pre></div>");
|
||||
Materialize.toast($toastContent, 2000);
|
||||
listdir(document.getElementById('fbheader').innerHTML);
|
||||
document.getElementById('commitmessage').value = "";
|
||||
listdir(document.getElementById('fbheader').innerHTML)
|
||||
document.getElementById('currentfile').value='';editor.setValue('');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2054,55 +1844,6 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
}
|
||||
}
|
||||
|
||||
function newfile(filename) {
|
||||
var path = document.getElementById('fbheader').innerHTML;
|
||||
if (path.length > 0 && filename.length > 0) {
|
||||
data = new Object();
|
||||
data.path = path;
|
||||
data.name = filename;
|
||||
$.post("api/newfile", data).done(function(resp) {
|
||||
if (resp.error) {
|
||||
var $toastContent = $("<div><pre>" + resp.message + "\n" + resp.path + "</pre></div>");
|
||||
Materialize.toast($toastContent, 5000);
|
||||
}
|
||||
else {
|
||||
var $toastContent = $("<div><pre>" + resp.message + "</pre></div>");
|
||||
Materialize.toast($toastContent, 2000);
|
||||
}
|
||||
listdir(document.getElementById('fbheader').innerHTML);
|
||||
document.getElementById('newfilename').value = '';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function upload() {
|
||||
var file_data = $('#uploadfile').prop('files')[0];
|
||||
var form_data = new FormData();
|
||||
form_data.append('file', file_data);
|
||||
form_data.append('path', document.getElementById('fbheader').innerHTML);
|
||||
$.ajax({
|
||||
url: 'api/upload',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
data: form_data,
|
||||
type: 'post',
|
||||
success: function(resp){
|
||||
if (resp.error) {
|
||||
var $toastContent = $("<div><pre>Error: " + resp.message + "</pre></div>");
|
||||
Materialize.toast($toastContent, 2000);
|
||||
}
|
||||
else {
|
||||
var $toastContent = $("<div><pre>Upload succesful</pre></div>");
|
||||
Materialize.toast($toastContent, 2000);
|
||||
listdir(document.getElementById('fbheader').innerHTML);
|
||||
document.getElementById('uploadform').reset();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
ace.require("ace/ext/language_tools");
|
||||
|
@ -2169,6 +1910,7 @@ INDEX = Template(r"""<!DOCTYPE html>
|
|||
var foldstatus = true;
|
||||
|
||||
function toggle_fold() {
|
||||
// Not used for now. We'll put a few buttons on top of the editor -> Toolbar. (Search, folding etc.)
|
||||
if (foldstatus) {
|
||||
editor.getSession().foldAll();
|
||||
}
|
||||
|
@ -2623,10 +2365,44 @@ class RequestHandler(BaseHTTPRequestHandler):
|
|||
print(response)
|
||||
|
||||
except Exception as err:
|
||||
response['message'] = "Not a git repository" % (str(err))
|
||||
response['message'] = "Not a git repository: %s" % (str(err))
|
||||
print("Exception (no repo): %s" % str(err))
|
||||
else:
|
||||
response['message'] = "Missing path"
|
||||
elif req.path == '/api/checkout':
|
||||
try:
|
||||
postvars = parse_qs(self.rfile.read(length).decode('utf-8'), keep_blank_values=1)
|
||||
except Exception as err:
|
||||
print(err)
|
||||
response['message'] = "%s" % (str(err))
|
||||
postvars = {}
|
||||
if 'path' in postvars.keys() and 'branch' in postvars.keys():
|
||||
if postvars['path'] and postvars['branch']:
|
||||
try:
|
||||
branchpath = unquote(postvars['path'][0])
|
||||
response['path'] = branchpath
|
||||
branch = unquote(postvars['branch'][0])
|
||||
repo = REPO(branchpath, search_parent_directories=True)
|
||||
try:
|
||||
head = [h for h in repo.heads if h.name == branch][0]
|
||||
head.checkout()
|
||||
response['error'] = False
|
||||
response['message'] = "Checked out %s" % branch
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type', 'text/json')
|
||||
self.end_headers()
|
||||
self.wfile.write(bytes(json.dumps(response), "utf8"))
|
||||
return
|
||||
except Exception as err:
|
||||
response['error'] = True
|
||||
response['message'] = str(err)
|
||||
print(response)
|
||||
|
||||
except Exception as err:
|
||||
response['message'] = "Not a git repository: %s" % (str(err))
|
||||
print("Exception (no repo): %s" % str(err))
|
||||
else:
|
||||
response['message'] = "Missing path or branch"
|
||||
elif req.path == '/api/newfolder':
|
||||
try:
|
||||
postvars = parse_qs(self.rfile.read(length).decode('utf-8'), keep_blank_values=1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue