1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/taskboard_ynh.git synced 2024-09-03 20:26:27 +02:00

Merge branch 'master' into testing

This commit is contained in:
ericgaspar 2023-01-07 07:43:28 +01:00
commit d84ea08e39
6 changed files with 185 additions and 3 deletions

View file

@ -15,7 +15,8 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview ## Overview
Kanban-inspired app for keeping track of things that need to get done A Kanban-inspired app for keeping track of things that need to get done.
The goal of TaskBoard is to provide a simple and clean interface to a functional and minimal application for keeping track of tasks. It's not trying to be the next Trello or LeanKit.
**Shipped version:** 1.0.2~ynh2 **Shipped version:** 1.0.2~ynh2

View file

@ -11,7 +11,8 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
## Vue d'ensemble ## Vue d'ensemble
Application inspirée de Kanban pour garder une trace des choses à faire A Kanban-inspired app for keeping track of things that need to get done.
The goal of TaskBoard is to provide a simple and clean interface to a functional and minimal application for keeping track of tasks. It's not trying to be the next Trello or LeanKit.
**Version incluse :** 1.0.2~ynh2 **Version incluse :** 1.0.2~ynh2

164
conf/Mailer.php Normal file
View file

@ -0,0 +1,164 @@
<?php
use PHPMailer\PHPMailer\PHPMailer;
class Mailer {
// Edit these values for your email setup.
const USE_SENDMAIL = true; // If false, uses SMTP settings below
const FROM_EMAIL = 'taskboard@__DOMAIN__';
const FROM_NAME = 'TaskBoard';
// SMTP Settings - Not used if USE_SENDMAIL is true
const SMTP_HOST = 'smtp.gmail.com';
const SMTP_PORT = 587;
const SMTP_USER = 'you@gmail.com';
const SMTP_PASS = 'yourPassword';
// End SMTP Settings
// DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
private $strings;
private $mail;
public function __construct(string $lang)
{
$this->loadStrings($lang);
}
/**
* Send email to one or more users in the provided list.
*
* @param $emails List of email addresses (must have at least one).
* @param $data Object containing template type and replacements for template.
*/
public function sendMail($emails, $data) {
$this->initMail();
if (count($emails) < 1) {
return '';
}
foreach($emails as $user) {
$this->mail->addAddress($user);
}
$this->mail->Subject = $this->strings->mail_subject;
$this->mail->msgHTML($this->parseTemplate($data));
if (!$this->mail->send()) {
return $this->strings->mail_error;
}
return $this->strings->mail_sent; // @codeCoverageIgnore
}
private function parseTemplate(EmailData $data) {
$template = $this->getTemplate($data->type);
$template = str_replace('%hostUrl%', $data->hostUrl, $template);
$template = str_replace('%boardId%', $data->boardId, $template);
$template = str_replace('%username%', $data->username, $template);
$template = str_replace('%boardName%', $data->boardName, $template);
$template = str_replace('%comment%', $data->comment, $template);
$template = str_replace('%taskName%', $data->taskName, $template);
$template =
str_replace('%taskDescription%', $data->taskDescription, $template);
$template = str_replace('%taskDueDate%', $data->taskDueDate, $template);
$template = str_replace('%taskAssignees%', $data->taskAssignees, $template);
$template =
str_replace('%taskCategories%', $data->taskCategories, $template);
$template = str_replace('%taskPoints%', $data->taskPoints, $template);
$template =
str_replace('%taskColumnName%', $data->taskColumnName, $template);
$template = str_replace('%taskPosition%', $data->taskPosition, $template);
return $template;
}
/**
* @codeCoverageIgnore
*/
private function getTemplate($type) {
$template = '';
switch($type) {
case 'newBoard':
$template = $this->strings->mail_template_newBoard;
break;
case 'newComment':
$template = $this->strings->mail_template_newComment;
break;
case 'newTask':
$template = $this->strings->mail_template_newTask;
case 'editBoard':
$template = $this->strings->mail_template_editBoard;
break;
case 'editComment':
$template = $this->strings->mail_template_editComment;
break;
case 'editTask':
$template = $this->strings->mail_template_editTask;
break;
case 'removeBoard':
$template = $this->strings->mail_template_removeBoard;
break;
case 'removeComment':
$template = $this->strings->mail_template_removeComment;
break;
case 'removeTask':
$template = $this->strings->mail_template_removeTask;
break;
}
$template .= $this->strings->mail_template_openBoardLink;
return $template;
}
private function initMail() {
$this->mail = new PHPMailer();
$this->mail->isSendmail();
$this->mail->setFrom(Mailer::FROM_EMAIL, Mailer::FROM_NAME);
$this->mail->CharSet = PHPMailer::CHARSET_UTF8;
// @codeCoverageIgnoreStart
if (!Mailer::USE_SENDMAIL) {
$this->mail->isSMTP();
$this->mail->Host = Mailer::SMTP_HOST;
$this->mail->Port = Mailer::SMTP_PORT;
$this->mail->Username = Mailer::SMTP_USER;
$this->mail->Password = Mailer::SMTP_PASS;
$this->mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$this->mail->SMTPAuth = true;
}
// @codeCoverageIgnoreEnd
}
private function loadStrings($lang) {
$json = '{}';
try {
$json =
file_get_contents(__DIR__ . '/../../strings/' . $lang . '_api.json');
} catch (Exception $ex) {
$ex->getMessage();
$json = file_get_contents(__DIR__ . '/../../json/' . $lang . '_api.json');
}
$this->strings = json_decode($json);
}
}

View file

@ -8,6 +8,8 @@ location __PATH__/ {
client_max_body_size 100M; client_max_body_size 100M;
client_body_buffer_size 128k; client_body_buffer_size 128k;
proxy_set_header Authorization $http_authorization;
proxy_pass_header Authorization;
try_files $uri $uri/ @__NAME__; try_files $uri $uri/ @__NAME__;

2
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1,2 @@
A Kanban-inspired app for keeping track of things that need to get done.
The goal of TaskBoard is to provide a simple and clean interface to a functional and minimal application for keeping track of tasks. It's not trying to be the next Trello or LeanKit.

View file

@ -70,6 +70,7 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
chmod 750 "$final_path" chmod 750 "$final_path"
chmod 777 "$final_path/api"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
@ -84,12 +85,23 @@ ynh_add_nginx_config
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring PHP-FPM..." --weight=3 ynh_script_progression --message="Configuring PHP-FPM..." --weight=4
# Create a dedicated PHP-FPM config # Create a dedicated PHP-FPM config
ynh_add_fpm_config --package="$extra_php_dependencies" ynh_add_fpm_config --package="$extra_php_dependencies"
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=2
dir="__DIR__"
ynh_add_config --template="../conf/Mailer.php" --destination="$final_path/api/helpers/Mailer.php"
chmod 400 "$final_path/api/helpers/Mailer.php"
chown $app:$app "$final_path/api/helpers/Mailer.php"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================