Browse files

Various cleaning up and moving old files into the unused/ folder. Add…

…ed in the group email functionality.
  • Loading branch information...
1 parent a3db3bd commit 9f89dc268f05c8b9fbe58ffd70296c65c84a20df @samwho committed Jan 8, 2011
View
2 classes/class.Config.php
@@ -1,6 +1,4 @@
<?php
-require_once 'class.PullRequestDatabase.php';
-
/**
* Static class to return the config array.
*
View
10 classes/class.PullRequestCrawl.php
@@ -36,11 +36,21 @@ public function run() {
if (count($requests) > 0) {
//Send the requests all in one email
if ($this->config['group_requests']) {
+
$formatted_pull_requests = '';
foreach ($requests as $request) {
$formatted_pull_requests .= TemplateParser::parse(
'templates/pull_request_group.tpl', $request);
}
+
+ $group_email_placeholders =
+ array('pull_requests' => $formatted_pull_requests);
+
+ $content = TemplateParser::parse(
+ 'templates/group_request_email.tpl', $request, $group_email_placeholders);
+
+ Email::send($content);
+
} else {
//Send requests in multiple emails
foreach ($requests as $request) {
View
16 config.inc.php
@@ -25,19 +25,31 @@
* Details for sending emails.
*/
+// The email address to send to.
$PULL_REQUEST_BOT['email_to'] = 'moshersam@gmail.com';
+
+// The email address to display in the "from" field.
$PULL_REQUEST_BOT['email_from'] = 'moshersam@gmail.com';
+
+// The subject of the email.
$PULL_REQUEST_BOT['email_subject'] = 'New ThinkUp Pull Requests';
+
+// The email to send replies to.
$PULL_REQUEST_BOT['reply_to'] = 'moshersam@gmail.com';
+
+// Whether or not you are using HTML in the email.
$PULL_REQUEST_BOT['email_use_html'] = true;
+
// Set this to true if you want to group multiple pull requests into one email.
-// This currently is not implemented.
-$PULL_REQUEST_BOT['group_requests'] = false;
+$PULL_REQUEST_BOT['group_requests'] = true;
/*
* Details for the repository you want to fetch pull requests from.
*/
+// The user that created the repo.
$PULL_REQUEST_BOT['repo_user'] = 'ginatrapani';
+
+// The name of the repo.
$PULL_REQUEST_BOT['repo_name'] = 'ThinkUp';
?>
View
0 last_pull.txt
No changes.
View
14 templates/group_request_email.tpl
@@ -0,0 +1,14 @@
+<html>
+ <head>
+ </head>
+ <body>
+ <h2>New pull requests!</h2>
+ <br />
+ [+pull_requests+]
+ <br /><br />
+ Please help ThinkUp by reviewing pull requests and offering code review! :)
+ <br />
+ Thanks,<br />
+ ThinkUp
+ </body>
+</html>
View
8 templates/pull_request_group.tpl
@@ -0,0 +1,8 @@
+<html>
+ <head>
+ </head>
+ <body>
+ <a href="[+link+]" target="_blank">[+title+]</a> - by [+user_real_name+]
+ <br />
+ </body>
+</html>
View
37 templates/template_readme.txt
@@ -0,0 +1,37 @@
+The templating in this request bot is a very simple placeholder replacement
+system. Nothing fancy, nothing like Smarty templates, just placeholder
+replacement.
+
+It is, however, pretty customisable. By default, placeholders are delimited
+[+like this+]. So the token there is the "like this" and the "delimiters" are
+the square brackets and the plus symbols.
+
+All template parsing happens in classes/class.TemplateParser.php. In this class
+you can change the delimiters and you can change the tokens.
+
+The currently available tokens are:
+
+'title' - pull request title
+'user_real_name' - the full, real name of the user who issued the pull.
+'user_login' - the login name of the user who issued the pull.
+'gravatar_id' - the id of the user's gravatar.
+'gravatar' - an img html tag containing the gravatar url and alt text.
+'created_at' - the date and time that the pull was created.
+'body' - the contents of the pull request body.
+'link' - a link to the pull request. Not in an <a> tag, just a URL.
+
+These placeholders persist through all .tpl files apart from
+'group_request_email.tpl' that only has one placeholder and that is the
+"pull_request" token that contains all pull requests after being parsed through
+the 'pull_request_group.tpl' template.
+
+Current .tpl files available:
+
+'pull_request_single.tpl' - this is used when you are sending an individual
+email for each pull request the crawler finds. In the config file, if you
+set the 'group_requests' to false, this is the .tpl file that will be used.
+
+'pull_request_group.tpl' - If you set the 'group_requests' value to true in the
+config file, this .tpl is used FOR EACH PULL REQUEST. It is for a SINGLE PULL
+REQUEST. All pull requests will be formatted like this. Look at
+'group_request_email.tpl' for the formatting of the entire email.
View
0 classes/class.PullRequestBotInstall.php → unused/class.PullRequestBotInstall.php
File renamed without changes.
View
0 classes/class.PullRequestDatabase.php → unused/class.PullRequestDatabase.php
File renamed without changes.
View
0 install.php → unused/install.php
File renamed without changes.

0 comments on commit 9f89dc2

Please sign in to comment.