update travis and some stuff

Former-commit-id: 7b81b0828f72d824080ac47d5724bf8301b35947
This commit is contained in:
Henrique Dias 2017-01-03 17:06:04 +00:00
parent 4c4d80166c
commit 01b475f4f0
5 changed files with 314 additions and 310 deletions

View File

@ -5,20 +5,14 @@ root = true
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,go}]
charset = utf-8
trim_trailing_whitespace = true
# 4 space indentation
[*.go]
indent_style = tab
indent_size = 2
# Indentation override for all JS under lib directory
[*.js]
indent_style = space
indent_size = 2
indent_size = 4

View File

@ -1,13 +1,18 @@
language: go
go:
- tip
sudo: false
install:
- go generate
- go get -u -v $(go list -f '{{join .Imports "\n"}}' ./... | sort | uniq | grep -v caddy-filemanager)
- go get -u -v github.com/mholt/caddy/caddyhttp
- go get -u -v github.com/caddyserver/caddydev
- go install github.com/caddyserver/caddydev
- go generate
- go get -u -v $(go list -f '{{join .Imports "\n"}}' ./... | sort | uniq | grep -v caddy-filemanager)
- go get -u -v github.com/mholt/caddy/caddyhttp
- go get -u -v github.com/caddyserver/caddydev
- go install github.com/caddyserver/caddydev
- go get github.com/gordonklaus/ineffassign
script:
- sed -i 's/\_ \"github.com\/mholt\/caddy\/caddyhttp\"/\_ \"github.com\/mholt\/caddy\/caddyhttp\"\n\_ \"github.com\/hacdias\/caddy-filemanager\"/g' $GOPATH/src/github.com/mholt/caddy/caddy/caddymain/run.go
- go build github.com/mholt/caddy/caddy
- sed -i 's/\_ \"github.com\/mholt\/caddy\/caddyhttp\"/\_ \"github.com\/mholt\/caddy\/caddyhttp\"\n\_ \"github.com\/hacdias\/caddy-filemanager\"/g' $GOPATH/src/github.com/mholt/caddy/caddy/caddymain/run.go
- go build github.com/mholt/caddy/caddy
- diff <(echo -n) <(gofmt -s -d .)
- ineffassign .

View File

@ -15,7 +15,7 @@
"end_with_newline": false, // End output with newline
"indent_char": " ", // Indentation character
"indent_level": 0, // Initial indentation level
"indent_size": 4, // Indentation size
"indent_size": 2, // Indentation size
"indent_with_tabs": false, // Indent with tabs, overrides `indent_size` and `indent_char`
"jslint_happy": false, // If true, then jslint-stricter mode is enforced
"keep_array_indentation": false, // Preserve array indentation

View File

@ -121,7 +121,6 @@ function getCSSRule(rules) {
* * * * * * * * * * * * * * * */
// TODO: here, we should create an abstraction layer from the webdav.
// We must create functions that do the requests to the webdav backend.
// this functions will contain a 'callback' to be used withing the other function.
webdav.move = function(oldLink, newLink) {
return new Promise((resolve, reject) => {
@ -140,6 +139,22 @@ webdav.move = function(oldLink, newLink) {
});
}
webdav.put = function(link, body) {
return new Promise((resolve, reject) => {
let request = new XMLHttpRequest();
request.open('PUT', toWebDavURL(link), true);
request.onload = () => {
if (request.status == 201) {
resolve(request.response);
} else {
reject(request.statusText);
}
}
request.onerror = () => reject(request.statusText);
request.send(body);
});
}
/* * * * * * * * * * * * * * * *
* *

View File

@ -67,20 +67,12 @@ listing.itemDrop = function(e) {
if (el.id === id) return;
let oldLink = toWebDavURL(document.getElementById(id).dataset.url),
newLink = toWebDavURL(el.dataset.url + name),
request = new XMLHttpRequest();
let oldLink = document.getElementById(id).dataset.url,
newLink = el.dataset.url + name;
request.open('MOVE', oldLink);
request.setRequestHeader('Destination', newLink);
request.send();
request.onreadystatechange = function() {
if (request.readyState == 4) {
if (request.status == 201 || request.status == 204) {
listing.reload();
}
}
}
webdav.move(oldLink, newLink)
.then(() => listing.reload())
.catch(e => console.log(e));
}
listing.documentDrop = function(event) {
@ -122,7 +114,8 @@ listing.rename = function(event) {
}
let link = item.dataset.url,
name = item.querySelector('.name').innerHTML;
field = item.querySelector('.name'),
name = field.innerHTML;
let submit = (event) => {
event.preventDefault();
@ -132,8 +125,7 @@ listing.rename = function(event) {
html = buttons.rename.querySelector('i').changeToLoading();
closePrompt(event);
webdav.move(link, newLink)
.then(data => {
webdav.move(link, newLink).then(() => {
listing.reload(() => {
newName = btoa(newName);
selectedItems = [newName];
@ -142,10 +134,11 @@ listing.rename = function(event) {
});
buttons.rename.querySelector('i').changeToDone(false, html);
})
.catch(error => {
item.querySelector('.name').innerHTML = name;
}).catch(error => {
field.innerHTML = name;
buttons.rename.querySelector('i').changeToDone(true, html);
console.log(error);
});
return false;
@ -165,24 +158,22 @@ listing.rename = function(event) {
}
listing.handleFiles = function(files, base) {
let button = document.getElementById("upload"),
html = button.querySelector('i').changeToLoading();
let html = buttons.upload.querySelector('i').changeToLoading(),
promises = [];
for (let i = 0; i < files.length; i++) {
let request = new XMLHttpRequest();
request.open('PUT', toWebDavURL(window.location.pathname + base + files[i].name));
for (let file of files) {
promises.push(webdav.put(window.location.pathname + base + file.name, file));
}
request.send(files[i]);
request.onreadystatechange = function() {
if (request.readyState == 4) {
if (request.status == 201) {
Promise.all(promises)
.then(() => {
listing.reload();
}
button.querySelector('i').changeToDone((request.status != 201), html);
}
}
}
buttons.upload.querySelector('i').changeToDone(false, html);
})
.catch(e => {
console.log(e);
buttons.upload.querySelector('i').changeToDone(true, html);
})
return false;
}
@ -320,7 +311,6 @@ listing.addDoubleTapEvent = function() {
Array.from(items).forEach(file => {
file.addEventListener('touchstart', event => {
console.log("hey")
if (touches.id != file.id) {
touches.id = file.id;
touches.count = 1;