Gossamer Forum
Quote Reply
Plugins in GMail
Hi,

I'm starting to do some work with Gmail - and so far its going ok (I've got a couple of cool plugins I want to write: Memo [ for "jotting" notes down, and Calander - which will be a calendar, where they can enter their own "special dates", and these will then show up on the their calander - and also when they login)

I've come across a bit of a roadblock though.

In GLinks, you can use:

Code:
Links::SiteHTML::display('template', { arg => $arg } );

... but I'm struggling to try and get this to work with GMail.

From looking at webmail.cgi, I've found:

Code:
GMail->print_page($page, @tags);

The problem I'm trying to get past - is how do you show a "basic" template (i.e a "core" template page, with folders, general header etc), so I can put my own content where I want it?

I tried:

Code:
GMail->print_page('memo_main.html');

..but that gives me an error:

Code:
A fatal error has occured:

Can't use an undefined value as an ARRAY reference at /path/to/admin/GMail/Folders.pm line 83.

Please enable debugging in setup for more details.

Can anyone shed any light?

TIA!

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Plugins in GMail In reply to
BTW, I've even tried the more basic method - of:

Code:
GT::Template->parse( 'memo_main.html' );

However, that gives me an error too:

Quote:
Software error:

GT::Template::Parser (392): Unable to open template file 'memo_main.html': File does not exist. at GT::Template::_compile_template line 596.

For help, please send mail to the webmaster ([no address given]), giving this error message and the time and date of the error.

A fatal error has occured:

[Mon Aug 20 05:43:19 2007] memo.cgi: GT::Template::Parser (392): Unable to open template file 'memo_main.html': File does not exist. at GT::Template::_compile_template line 596.

Please enable debugging in setup for more details.

That template definatly exists - but do I need to specify a "template set" for it, or similar?

TIA

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Plugins in GMail In reply to
I looked at the code, and it looks like you can't use print_page without loading a user first because print_page loads folder information.

Adrian
Quote Reply
Re: [brewt] Plugins in GMail In reply to
Hi,

Thanks for the reply. I'm still stuck though :(

Here's what I have so far:

Code:
#!/usr/local/bin/perl -w
# ==================================================================
# Gossamer Mail - enhanced email management system
#
# Website : http://gossamer-threads.com/
# Support : http://gossamer-threads.com/scripts/support/
# CVS Info : 087,070,083,091,083
# Revision : $Id: logout.cgi,v 1.23 2006/11/15 18:19:42 brewt Exp $
#
# Copyright (c) 2003 Gossamer Threads Inc. All Rights Reserved.
# Redistribution in part or in whole strictly prohibited. Please
# see LICENSE file for full details.
# ==================================================================

use strict;
use lib '/var/home/domain/domain.com/cgi-bin/mail/admin';
use GMail qw/:folders :objects/;
use GMail::Auth;
use GMail::NoAuth;

GMail::init('/var/home/domain/domain.com/cgi-bin/mail/admin');

$| = 1;
local $SIG{__DIE__} = \&GMail::fatal;

print $IN->header();

my $action= $IN->param('do');

if (!$action) {
# show HTML page showing their memos
# GMail->print_page('memo_main.html', @tags);
GMail->print_page('memo_main.html');
#GT::Template->parse( 'memo_main.html' );
} elsif ($action eq "add") {
# show page for adding a memo
} elsif ($action eq "delete") {
# show page for deleting a memo
} elsif ($action eq "modify") {
# show page for modifying a memo
}

As you may guess - this is for a "Memo" system :)

TIA!

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

Last edited by:

Andy: Aug 21, 2007, 2:21 AM
Quote Reply
Re: [brewt] Plugins in GMail In reply to
Hi,

Would it be easier to use a hook? Do you have any suggestions? I really wanna get working on at least 3 plugins for Gmail - but thus far, I've hit a roadblock, as I just can't get a basic .cgi script to work (which is imperative for what I want to do).

TIA

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Plugins in GMail In reply to
You need to authenticate the user. Take a look at how it's done in webmail.cgi.

Adrian
Quote Reply
Re: [brewt] Plugins in GMail In reply to
Hi,

I'm still confused :(

Could you perhaps mail / PM me a modified version of webmail.cgi, with just a simple function that prints out a template test.html template, with the core bits around it? Why couldn't it be as simple as GLinks <G>

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Plugins in GMail In reply to
Code:
#!/usr/bin/perl -w

use strict;
use lib '.';

use GMail qw/:all/;
use GMail::Auth;

GMail::init('.');

$SIG{__DIE__} = \&GMail::fatal;
$| = 1;

main();

sub main {
# Load all template specific files.
my $t = GMail->template_set();
$CFG->load_template_set($t);

# If this site is disabled display the disabled page
if (!$CFG->{enabled}) {
return GMail->print_page('disabled.htm');
}

# Check to see if they are allowed to use the service
if (!GMail::Auth->allow_access()) {
require GMail::NoAuth;
return GMail::NoAuth->print_page($CFG->{templates}->{auth_error}, { error => ref($GMail::Auth::error) ? $GMail::Auth::error : \$GMail::Auth::error });
}

# Authenticate the user.
$GMail::Auth::error ||= ''; # -w warnings, ugg
my $ret = $PLG->dispatch('GMail::Auth::authenticate', sub { GMail::Auth->authenticate() });
unless ($ret) {
require GMail::NoAuth;
return GMail::NoAuth->auth_failed({ error => $GMail::Auth::error });
}

return $ret if $ret == EXIT;

# Find out which template set we are on.
$t = GMail->template_set();
$CFG->load_template_set($t);

GMail->print_page('foo.htm', { foo => "bar" });
}

Adrian
Quote Reply
Re: [brewt] Plugins in GMail In reply to
Thank you, thank you, thank you Smile

Works like a charm. Now, just to get these plugins written =)

Thanks again Cool

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates