Wednesday, April 4, 2007

GTD-PHP













I have been looking for a replacement to Next Action for tracking my tasks after it became way too when a lot of tasks got added. I tried Tack Coach for a bit but found it didn't present the tasks I need to do ina clear enough fashion. So after some Review I came across GTD-PHP a web based app which seems to do the trick. I hosted a copy on Burst and after making some small sql changes (Burst still uses mysql 4.0 something) I was off and running.
I find as soon as a task comes into my head I need to record it or its lost and the less resistance to recording the task the better so I wrote a small perl program that will add tasks to PHP-GTD with out me needing to open a web page etc. It only lets you enter the basic items required to create a new action and its very basic, I only spent an hour knocking it up.

To run it you will need Perl with the modules wxperl and WWW::Mechanize installed.

copy and paste the code below into a new file and save as gtdqa.pl. Follow the installation instructions at the top of the file.

#!/usr/bin/perl
#############################################################################
## Name: gtdqa.pl
## Purpose: Quickly Add new actions to GTD-PHP
## Author: Michael Mueller
## Modified by:
## Created: 05/04/2007
## Copyright: (c) 2007 Michael Mueller
## Based on a script a WX example script by Mattia Barbon
## Licence:
## This program is free software; you can redistribute it and/or
## modify it under the same terms as Perl itself
## Installation:
## You will need WX perl and WWW::Mechanize installed
## In the same Directory that this script is in you will require
## 3 files
## project.txt with the names of all your PHP-GTD projects
## one per line.
## context.txt with the names of all your PHP-GTD contexts
## one per line.
## config.txt with the url to your installation on the first line
## for example www.somwhere.com/php-gtd
## if you have your site password protected with basic AUTH
## you can do user:password@www.somwhere.com/php-gtd
## Usage:
## Run the Script "perlw gtdqa.pl" enter the subject and
## description of your task select the Project and Context
## Trouble Shooting:
## Note this script does no error checking if it does not
## seem to work run it in a cmd shell with perl gtdqa.pl
## and see if any thing is printed to shell when you try to add
## an action.
##
#############################################################################

use Wx;

package MyApp;

use strict;
use vars qw(@ISA);

@ISA=qw(Wx::App);

use Wx qw(wxDefaultSize wxDefaultPosition);

sub OnInit {
my( $this ) = @_;

my( $dialog ) = MyDialog->new( "wxPerl dialog sample",
wxDefaultPosition,
);

$this->SetTopWindow( $dialog );

$dialog->Show( 1 );

1;
}

package MyDialog;

use strict;
use vars qw(@ISA);
use WWW::Mechanize;
@ISA=qw(Wx::Dialog);
use FindBin qw($Bin);
use Wx::Event qw(EVT_CLOSE EVT_BUTTON);
use Wx qw(wxDefaultSize wxDefaultValidator wxTE_MULTILINE);
my $mech = WWW::Mechanize->new();
my $config = loadParams($Bin.'config');
my $url = $config->[0].'/item.php?type=' ;


sub new {
my( $class ) = shift;
my( $this ) = $class->SUPER::new( undef, -1, 'PHP-GTD', [450, 250] );

# $this->SetIcon( Wx::GetWxPerlIcon() );
my $contexts = loadParams($Bin.'contexts');
my $projects = loadParams($Bin.'projects');
my( $ct ) = $this->{SUBJECT} =
Wx::TextCtrl->new( $this, -1, undef, [20, 20], [350, -1]);



my( $cb ) = Wx::Button->new( $this, -1, 'Submit', [300, 190] );


my( $p ) = $this->{PROJECT} = Wx::ComboBox->new( $this, -1, undef, [20,50],
[100,-1],
$projects );
my( $c ) = $this->{CONTEXT} = Wx::ComboBox->new( $this, -1, undef, [130,50],
[100,-1],
$contexts );

my( $ct ) = $this->{DESCRIPTION} =
Wx::TextCtrl->new( $this, -1, undef, [20, 80], [350, 100], wxTE_MULTILINE );

# my($cbx) = $this->{SOMEDAY} = ( $this, -1, 'Submit', [100, 200] );
# Wx::CheckBox->new($this, -1, 'Someday', [100, 200] );

EVT_BUTTON( $this, $cb, \&submit );

EVT_CLOSE( $this, \&OnClose );

$this;
}

sub submit {
my( $this, $event ) = @_;

my $subject = $this->{SUBJECT}->GetValue();
my $context = $this->{CONTEXT}->GetValue();
my $project = $this->{PROJECT}->GetValue();
my $description = $this->{DESCRIPTION}->GetValue();
my $type;
$type = 'a';
$mech->get( $url.$type );
$mech->submit_form(
form_number => 1,
fields => {
title => $subject,
description => $description,
projectId => $project,
contextId => $context,


}
);
$this->{SUBJECT}->SetValue('');
$this->{DESCRIPTION}->SetValue('');
}

sub loadParams
{
my ($fileName) = @_;
open (IF, $fileName.".txt")or die "Can not open File";
my @params = ;
chomp @params;
return \@params;
}


sub OnClose {
my( $this, $event ) = @_;

$this->Destroy();
}

package main;

my( $app ) = MyApp->new();

$app->MainLoop();

No comments: