Skip to content

Commit 04a40ce

Browse files
author
Jeffrey Alvarez Massón
committed
Commit tasks is ready. Corrected bugs.
1 parent be0de0e commit 04a40ce

15 files changed

+2942
-49
lines changed

.tasks/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
server.pid
2-
server.log
2+
server.log

.tasks/common.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
*/
1010
String.prototype.replaceAll = function(whichText, withText) {
1111
var inText = this.toString();
12-
while (inText.indexOf(whichText) >= 0) {
13-
inText = inText.replace(whichText, withText);
14-
}
15-
return inText;
12+
var parts = inText.split(whichText);
13+
var result = parts.join(withText);
14+
return result;
1615
};
1716

1817
/**
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"pending": 2,
3-
"estimation": 2,
4-
"title": "Add a Commit to the main menu",
2+
"pending": "0",
3+
"estimation": "1",
4+
"title": "Add a Commit option to the main menu",
55
"tags": "webpage",
66
"id": "1748c43c936a3d47a978ac25be1c1837801604786d6dfe4a39ab6b70a70f0aa8",
77
"createdAt": 1470613701495,
8-
"updatedAt": 1470684398454,
9-
"status": "open",
8+
"updatedAt": 1470711003520,
9+
"status": "done",
1010
"gitStatus": "M "
1111
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"pending": "0",
3+
"estimation": "1",
4+
"title": "When a task is dropped in the label of the same task or another task, it loses the status attribute",
5+
"tags": "webpage,bug",
6+
"gitStatus": "A ",
7+
"status": "done",
8+
"id": "3bd5bed3a2def4e1eab802cfded50b45081783067b8113019f6fd9f0d0689cfa",
9+
"createdAt": 1470708880068,
10+
"updatedAt": 1470709422593
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"status": "done",
3+
"pending": "0",
4+
"estimation": 1,
5+
"title": "It cannot discard changes on added or excluded tasks",
6+
"tags": "webpage,bug",
7+
"gitStatus": "A ",
8+
"id": "b55239df5a5dd782b7f4a5f5d4862f75060fd289c3f76eb33cd0ade477df35c1",
9+
"createdAt": 1470707948527,
10+
"updatedAt": 1470708078914
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"status": "done",
3+
"pending": "0",
4+
"estimation": "1",
5+
"title": "Corrected that the edit task form was saving read-only values.",
6+
"tags": "webpage,bug",
7+
"gitStatus": "A ",
8+
"id": "cff8da194b99f115f80a0935f8108ebe79ca5183b17412f988e32548b2c7cef7",
9+
"createdAt": 1470706545374,
10+
"updatedAt": 1470706701581
11+
}

.tasks/server.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ function gitCheckout(fileName) {
105105
git('checkout -- ' + fileName.quote());
106106
}
107107

108+
/**
109+
* Commits with git.
110+
*/
111+
function gitCommit(message) {
112+
var messageArg = "";
113+
if (message) {
114+
messageArg = "-m " + message.quote();
115+
}
116+
git('commit ' + messageArg + " -- " + __dirname.quote());
117+
}
118+
108119
/**
109120
* Gets the current git branch.
110121
*/
@@ -167,7 +178,7 @@ function serveFile(res, pathname) {
167178
fileName = path.sep != '/' ?
168179
fileName.replaceAll('/', path.sep) : fileName;
169180
fileName = __dirname + path.sep + fileName;
170-
console.log('Retrieving file %s.', fileName);
181+
console.log('GET: %s.', pathname);
171182
if (!fs.existsSync(fileName)) {
172183
res.writeHead(500, {});
173184
console.error("Invalid access to file '%s'.", fileName);
@@ -204,7 +215,7 @@ function reportSuccess(response, obj) {
204215
*/
205216
function reportError(response, errorMessage, exception) {
206217
if (exception) {
207-
console.error(JSON.stringify(exception));
218+
console.error("%s %s", errorMessage, JSON.stringify(exception));
208219
}
209220
response.writeHead(500, {'Content-type': 'application/json'});
210221
var responseBody = {
@@ -216,12 +227,10 @@ function reportError(response, errorMessage, exception) {
216227

217228
/**
218229
* Processes a POST request.
219-
* @param path URL pathname.
220-
* @param data Data received.
230+
* @param parsedData Parsed request data.
221231
* @param res HTTP Response.
222232
*/
223-
function postItem(path, data, res) {
224-
var parsedData = JSON.parse(data);
233+
function postItem(parsedData, res) {
225234
if (!parsedData.id) {
226235
parsedData.id = createItemId();
227236
}
@@ -319,9 +328,20 @@ function requestReceived(req, res) {
319328
req.on("data", function(chunk) {
320329
data += chunk;
321330
}).on("end", function() {
331+
console.log("%s: %s", req.method, parsedUrl.pathname);
322332
switch (req.method) {
323333
case 'POST':
324-
postItem(parsedUrl.pathname, data, res);
334+
try {
335+
data = JSON.parse(data);
336+
} catch (e) {
337+
reportError(res, 'Error parsing JSON.', e);
338+
return;
339+
}
340+
if (parsedUrl.pathname == "/tasks/commit") {
341+
gitCommit(data.msg);
342+
return;
343+
}
344+
postItem(data, res);
325345
break;
326346

327347
case 'GET':

0 commit comments

Comments
 (0)