Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
b4e01b6098 | |||
415c0e622f | |||
a9ba9d94f8 |
@ -1,8 +1,8 @@
|
|||||||
#Mon, 21 Oct 2013 14:00:48 +0000
|
#Wed, 30 Oct 2013 10:46:52 -0500
|
||||||
lib.local=true
|
lib.local=true
|
||||||
name=jdb-gtd
|
name=jdb-gtd
|
||||||
version=1.4
|
version=1.6
|
||||||
nailgun.classpath.dir=/home/jdbernard/programs/nailgun/classpath
|
nailgun.classpath.dir=/home/jdbernard/programs/nailgun/classpath
|
||||||
executable.jar=true
|
executable.jar=true
|
||||||
main.class=com.jdblabs.gtd.cli.GTDCLI
|
main.class=com.jdblabs.gtd.cli.GTDCLI
|
||||||
build.number=1
|
build.number=0
|
||||||
|
@ -23,7 +23,7 @@ import static com.jdblabs.gtd.Util.*
|
|||||||
* @org gtd.jdb-labs.com/cli/GTDCLI */
|
* @org gtd.jdb-labs.com/cli/GTDCLI */
|
||||||
public class GTDCLI {
|
public class GTDCLI {
|
||||||
|
|
||||||
public static final String VERSION = "1.3"
|
public static final String VERSION = "1.6"
|
||||||
private static String EOL = System.getProperty("line.separator")
|
private static String EOL = System.getProperty("line.separator")
|
||||||
|
|
||||||
/// We have a persistent instance when we are in the context of a Nailgun
|
/// We have a persistent instance when we are in the context of a Nailgun
|
||||||
@ -318,51 +318,59 @@ public class GTDCLI {
|
|||||||
protected void done(LinkedList args) {
|
protected void done(LinkedList args) {
|
||||||
|
|
||||||
def selectedFilePath = args.poll()
|
def selectedFilePath = args.poll()
|
||||||
def selectedFile = new File(selectedFilePath)
|
|
||||||
|
|
||||||
if (!selectedFile) {
|
if (!selectedFilePath) {
|
||||||
println "gtd done command requires a <action-file> parameter."
|
println "gtd done command requires a <action-file> parameter."
|
||||||
return }
|
return }
|
||||||
|
|
||||||
def item
|
while (selectedFilePath) {
|
||||||
if (selectedFile.isAbsolute()) item = new Item(selectedFile)
|
def item
|
||||||
else item = new Item(new File(workingDir, selectedFilePath))
|
def selectedFile = new File(selectedFilePath)
|
||||||
|
|
||||||
/// Move to the done folder.
|
if (!selectedFile.exists() || !selectedFile.isFile()) {
|
||||||
def oldFile = item.file
|
println "File does not exist or is a directory:"
|
||||||
def date = new DateMidnight().toString("YYYY-MM-dd")
|
println "\t" + selectedFile.canonicalPath
|
||||||
item.file = new File(gtdDirs.done, "$date-${item.file.name}")
|
continue }
|
||||||
item.save()
|
|
||||||
|
|
||||||
/// Check if this item was in a project folder.
|
if (selectedFile.isAbsolute()) item = new Item(selectedFile)
|
||||||
if (inPath(gtdDirs.projects, oldFile)) {
|
else item = new Item(new File(workingDir, selectedFilePath))
|
||||||
|
|
||||||
/// Delete any copies of this item from the next actions folder.
|
/// Move to the done folder.
|
||||||
findAllCopies(oldFile, gtdDirs."next-actions").each { file ->
|
def oldFile = item.file
|
||||||
println "Deleting duplicate entry from the " +
|
def date = new DateMidnight().toString("YYYY-MM-dd")
|
||||||
"${file.parentFile.name} context."
|
item.file = new File(gtdDirs.done, "$date-${item.file.name}")
|
||||||
file.delete() }
|
item.save()
|
||||||
|
|
||||||
/// Delete any copies of this item from the waiting folder.
|
/// Check if this item was in a project folder.
|
||||||
findAllCopies(oldFile, gtdDirs.waiting).each { file ->
|
if (inPath(gtdDirs.projects, oldFile)) {
|
||||||
println "Deleting duplicate entry from the " +
|
|
||||||
"${file.parentFile.name} waiting context."
|
|
||||||
file.delete() }}
|
|
||||||
|
|
||||||
/// Check if this item was in the next-action or waiting folder.
|
/// Delete any copies of this item from the next actions folder.
|
||||||
if (inPath(gtdDirs["next-actions"], oldFile) ||
|
findAllCopies(oldFile, gtdDirs."next-actions").each { file ->
|
||||||
inPath(gtdDirs.waiting, oldFile)) {
|
println "Deleting duplicate entry from the " +
|
||||||
|
"${file.parentFile.name} context."
|
||||||
|
file.delete() }
|
||||||
|
|
||||||
/// Delete any copies of this item from the projects folder.
|
/// Delete any copies of this item from the waiting folder.
|
||||||
findAllCopies(oldFile, gtdDirs.projects).each { file ->
|
findAllCopies(oldFile, gtdDirs.waiting).each { file ->
|
||||||
println "Deleting duplicate entry from the " +
|
println "Deleting duplicate entry from the " +
|
||||||
"${file.parentFile.name} project."
|
"${file.parentFile.name} waiting context."
|
||||||
file.delete() }}
|
file.delete() }}
|
||||||
|
|
||||||
/// Delete the original
|
/// Check if this item was in the next-action or waiting folder.
|
||||||
oldFile.delete()
|
if (inPath(gtdDirs["next-actions"], oldFile) ||
|
||||||
|
inPath(gtdDirs.waiting, oldFile)) {
|
||||||
|
|
||||||
println "'$item' marked as done." }
|
/// Delete any copies of this item from the projects folder.
|
||||||
|
findAllCopies(oldFile, gtdDirs.projects).each { file ->
|
||||||
|
println "Deleting duplicate entry from the " +
|
||||||
|
"${file.parentFile.name} project."
|
||||||
|
file.delete() }}
|
||||||
|
|
||||||
|
/// Delete the original
|
||||||
|
oldFile.delete()
|
||||||
|
|
||||||
|
selectedFilePath = args.poll()
|
||||||
|
println "'$item' marked as done." } }
|
||||||
|
|
||||||
/** #### `calendar`
|
/** #### `calendar`
|
||||||
* Implement the `calendar` command to show all the items which are
|
* Implement the `calendar` command to show all the items which are
|
||||||
@ -749,7 +757,7 @@ context or project is named, all contexts are listed."""
|
|||||||
* palatable for a filename. */
|
* palatable for a filename. */
|
||||||
public static String stringToFilename(String s) {
|
public static String stringToFilename(String s) {
|
||||||
return s.replaceAll(/\s/, '-').
|
return s.replaceAll(/\s/, '-').
|
||||||
replaceAll(/[';:(\.$)]/, '').
|
replaceAll(/[';:(\.$\/)]/, '').
|
||||||
toLowerCase() }
|
toLowerCase() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ public class GTDServlet extends HttpServlet {
|
|||||||
/// Get this user's session
|
/// Get this user's session
|
||||||
HttpSession session = request.getSession(true);
|
HttpSession session = request.getSession(true);
|
||||||
|
|
||||||
/// If the user is posting to `/gtd/login` then let's try to
|
/// If the user is posting to `/login` then let's try to
|
||||||
/// authenticate them. We don't care about the state of the existing
|
/// authenticate them. We don't care about the state of the existing
|
||||||
/// session.
|
/// session.
|
||||||
if (request.servletPath == '/login') {
|
if (request.servletPath == '/login') {
|
||||||
@ -161,8 +161,8 @@ public class GTDServlet extends HttpServlet {
|
|||||||
/// Right now there is no other endpoint that supports `POST`, so return
|
/// Right now there is no other endpoint that supports `POST`, so return
|
||||||
/// `404 Not Found` or `405 Method Not Allowed`
|
/// `404 Not Found` or `405 Method Not Allowed`
|
||||||
switch (request.servletPath) {
|
switch (request.servletPath) {
|
||||||
case ~/\/gtd\/contexts.*/:
|
case ~/\/contexts.*/:
|
||||||
case ~/\/gtd\/projects.*/:
|
case ~/\/projects.*/:
|
||||||
response.status = SC_METHOD_NOT_ALLOWED
|
response.status = SC_METHOD_NOT_ALLOWED
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
@ -207,14 +207,14 @@ public class GTDServlet extends HttpServlet {
|
|||||||
|
|
||||||
switch(request.servletPath) {
|
switch(request.servletPath) {
|
||||||
|
|
||||||
/// If they are invoking `/gtd/logout` then invalidate their session
|
/// If they are invoking `/logout` then invalidate their session
|
||||||
/// and return `200 OK`
|
/// and return `200 OK`
|
||||||
case "/logout":
|
case "/logout":
|
||||||
session.removeAttribute("authenticated")
|
session.removeAttribute("authenticated")
|
||||||
session.invalidate()
|
session.invalidate()
|
||||||
break
|
break
|
||||||
|
|
||||||
/// ##### `/gtd/contexts`
|
/// ##### `/contexts`
|
||||||
/// Return the list of contexts that are readable by this user.
|
/// Return the list of contexts that are readable by this user.
|
||||||
case "/contexts":
|
case "/contexts":
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ public class GTDServlet extends HttpServlet {
|
|||||||
writeJSON(returnData, response)
|
writeJSON(returnData, response)
|
||||||
break
|
break
|
||||||
|
|
||||||
/// ##### `/gtd/contexts/<contextId>`
|
/// ##### `/contexts/<contextId>`
|
||||||
/// Return data for the requested context, assuming it is
|
/// Return data for the requested context, assuming it is
|
||||||
/// readable for this user.
|
/// readable for this user.
|
||||||
case ~'/contexts/(.+)':
|
case ~'/contexts/(.+)':
|
||||||
@ -251,7 +251,7 @@ public class GTDServlet extends HttpServlet {
|
|||||||
writeJSON(returnData, response)
|
writeJSON(returnData, response)
|
||||||
break
|
break
|
||||||
|
|
||||||
/// ##### `/gtd/projects`
|
/// ##### `/projects`
|
||||||
/// Return the list of projects that are readable for this user.
|
/// Return the list of projects that are readable for this user.
|
||||||
case "/projects":
|
case "/projects":
|
||||||
/// Filter the project directories to find the ones that the
|
/// Filter the project directories to find the ones that the
|
||||||
@ -264,7 +264,7 @@ public class GTDServlet extends HttpServlet {
|
|||||||
writeJSON(returnData, response)
|
writeJSON(returnData, response)
|
||||||
break
|
break
|
||||||
|
|
||||||
/// ##### `/gtd/projects/<projectId>`
|
/// ##### `/projects/<projectId>`
|
||||||
/// Return data for the requested project, assuming it is readable
|
/// Return data for the requested project, assuming it is readable
|
||||||
/// for this user.
|
/// for this user.
|
||||||
case ~'/projects/(.+)':
|
case ~'/projects/(.+)':
|
||||||
@ -286,7 +286,7 @@ public class GTDServlet extends HttpServlet {
|
|||||||
writeJSON(returnData, response)
|
writeJSON(returnData, response)
|
||||||
break
|
break
|
||||||
|
|
||||||
/// ##### `/gtd/next-actions/<contexts-and-projects>`
|
/// ##### `/next-actions/<contexts-and-projects>`
|
||||||
/// Return all of the items contained in the named contexts and
|
/// Return all of the items contained in the named contexts and
|
||||||
/// projects, assuming the user has access to them.
|
/// projects, assuming the user has access to them.
|
||||||
/// `<contexts-and-projects>` is expected to be a comma-delimited
|
/// `<contexts-and-projects>` is expected to be a comma-delimited
|
||||||
|
Reference in New Issue
Block a user