watch: add 'watch' support
[girocco/ztw.git] / cgi / watchadd.cgi
blob097443a4dce0ace8620eb6b6f90a383b855b7944
1 #!/usr/bin/perl
2 # (c) Zachary T Welch <zw@superlucidity.net>
3 # GPLv2
5 use strict;
6 use warnings;
8 use lib qw(/home/repo/repomgr/cgi);
9 use Git::RepoCGI;
11 my $repo = Git::RepoCGI->new('Create Watchdog');
12 my $project = $repo->sparam('project');
13 my $branch = $repo->sparam('branch');
14 my $path = $repo->sparam('path');
15 my $user = $repo->sparam('user');
17 # check for submission
18 if ($project && $user && $repo->sparam('go')) {
19 my $watch = Git::RepoCGI::Watch->new($user, $project, $branch, $path);
20 $watch->add() or $repo->bye("Unable to create watchdog: $!");
21 $repo->bye("Watchdog created successfully.");
24 print <<EOT
26 <p>
27 Using the form on this page, you may register a <i>watchdog</i> that
28 will monitor a project or fork for any changes. When activity occurs,
29 you will be sent a notification of the changes via e-mail. You can set
30 watchdogs to trigger for any change in the project, or you can restrict
31 them to monitor changes that occur on a specific branch or path in the
32 repository tree.
33 </p>
34 <p>
35 <p>
36 Once created, you can <a href="watchedit.cgi">access your watchdogs</a>
37 to view, update, or delete them. Users with push access to a project
38 can <a href="watchspam.cgi?project=$project&branch=$branch&path=$path">send
39 messages</a> to registered watchers of a particular fork, branch, or path.
40 </p>
42 <h2>Create a Watchdog</h2>
43 <form method="post">
44 <p>Project: <input type="text" name="project" value="$project" /></p>
45 <p>Branch: <input type="text" name="branch" value="$branch" />
46 <sup>(optional)</sup></p>
47 <p>Path: <input type="text" name="path" value="$path" />
48 <sup>(optional)</sup></p>
49 <br>
50 <p>Account: <input type="text" name="user" value="$user" /></p>
51 <p>Password: <input type="password" name="cpwd" /></p>
52 <p><input type="submit" name="go" value="Watch" /></p>
53 </form>
54 EOT