Skip to content

Commit

Permalink
Merge pull request #41 from pxthinh/feature/add_view_template
Browse files Browse the repository at this point in the history
update view template for some github events
  • Loading branch information
tanhongit authored Dec 3, 2023
2 parents 42681e6 + d18bbca commit f8849bf
Show file tree
Hide file tree
Showing 23 changed files with 363 additions and 4 deletions.
2 changes: 2 additions & 0 deletions config/telegram-git-notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@

/** Set the path to the view file */
'view' => [
'ignore-message' => env('IGNORE_MESSAGE', 'ignore-message'),

'namespace' => env('TGN_VIEW_NAMESPACE', 'tg-notifier'),

'default' => env(
Expand Down
25 changes: 25 additions & 0 deletions lang/de/events/github/label.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

return [
'created' => [
'title' => '💬 <b>New Label</b> ⚠️ - 🦑:repo by :user',
],
'deleted' => [
'title' => '🗑 <b>Label Deleted</b> - 🦑:repo by :user',
],
'edited' => [
'title' => '👷‍♂️🛠️ <b>Label has been edited</b> - 🦑:repo by :user',
'changes' => [
'title' => [
'name' => '📖 <b>Title</b> has been changed',
'from' => '📝 <b>From:</b> :title_from',
'to' => '🏷 <b>To:</b> :title_to',
],
'description' => [
'name' => '📖 <b>Description</b> has been changed',
'from' => '📝 <b>From:</b> :description_from',
'to' => '🏷 <b>To:</b> :description_to',
],
],
],
];
20 changes: 20 additions & 0 deletions lang/de/events/github/pull_request.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,35 @@

return [
'review' => '👥 Reviewers: ',
'assigned' => [
'title' => '‍👷‍♂️🛠️ <b>Assigned Pull Request</b> - 🦑:repo by :user',
'body' => ':name has been assigned in the pull request <b>:pullRequest</b>',
],
'closed' => [
'title' => ':title - 🦑:repo by :user',
'title_merged' => '✅ <b>Pull Request Merged</b>',
'title_closed' => '🚫 <b>Pull Request Closed</b>',
],
'labeled' => [
'title' => '‍👷‍♂️🛠️ <b>Labeled Pull Request</b> - 🦑:repo by :user',
],
'locked' => [
'title' => '‍👷‍♂️🛠️ <b>Locked Pull Request</b> - 🦑:repo by :user',
],
'opened' => [
'title' => '👷‍♂️🛠️ <b>New Pull Request</b> - 🦑:repo by :user',
],
'reopened' => [
'title' => '👷‍♂️🛠️ <b>Reopened Pull Request</b> - 🦑:repo by :user',
],
'unassigned' => [
'title' => '‍👷‍♂️🛠️ <b>Unassigned Pull Request</b> - 🦑:repo by :user',
'body' => ':name has been unassigned in the pull request <b>:pullRequest</b>',
],
'unlabeled' => [
'title' => '‍👷‍♂️🛠️ <b>Unlabeled Pull Request</b> - 🦑:repo by :user',
],
'unlocked' => [
'title' => '‍👷‍♂️🛠️ <b>Unlocked Pull Request</b> - 🦑:repo by :user',
],
];
25 changes: 25 additions & 0 deletions lang/en/events/github/label.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

return [
'created' => [
'title' => '💬 <b>New Label</b> ⚠️ - 🦑:repo by :user',
],
'deleted' => [
'title' => '🗑 <b>Label Deleted</b> - 🦑:repo by :user',
],
'edited' => [
'title' => '👷‍♂️🛠️ <b>Label has been edited</b> - 🦑:repo by :user',
'changes' => [
'title' => [
'name' => '📖 <b>Title</b> has been changed',
'from' => '📝 <b>From:</b> :title_from',
'to' => '🏷 <b>To:</b> :title_to',
],
'description' => [
'name' => '📖 <b>Description</b> has been changed',
'from' => '📝 <b>From:</b> :description_from',
'to' => '🏷 <b>To:</b> :description_to',
],
],
],
];
20 changes: 20 additions & 0 deletions lang/en/events/github/pull_request.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,35 @@

return [
'review' => '👥 Reviewers: ',
'assigned' => [
'title' => '‍👷‍♂️🛠️ <b>Assigned Pull Request</b> - 🦑:repo by :user',
'body' => ':name has been assigned in the pull request <b>:pullRequest</b>',
],
'closed' => [
'title' => ':title - 🦑:repo by :user',
'title_merged' => '✅ <b>Pull Request Merged</b>',
'title_closed' => '🚫 <b>Pull Request Closed</b>',
],
'labeled' => [
'title' => '‍👷‍♂️🛠️ <b>Labeled Pull Request</b> - 🦑:repo by :user',
],
'locked' => [
'title' => '‍👷‍♂️🛠️ <b>Locked Pull Request</b> - 🦑:repo by :user',
],
'opened' => [
'title' => '👷‍♂️🛠️ <b>New Pull Request</b> - 🦑:repo by :user',
],
'reopened' => [
'title' => '👷‍♂️🛠️ <b>Reopened Pull Request</b> - 🦑:repo by :user',
],
'unassigned' => [
'title' => '‍👷‍♂️🛠️ <b>Unassigned Pull Request</b> - 🦑:repo by :user',
'body' => ':name has been unassigned in the pull request <b>:pullRequest</b>',
],
'unlabeled' => [
'title' => '‍👷‍♂️🛠️ <b>Unlabeled Pull Request</b> - 🦑:repo by :user',
],
'unlocked' => [
'title' => '‍👷‍♂️🛠️ <b>Unlocked Pull Request</b> - 🦑:repo by :user',
],
];
25 changes: 25 additions & 0 deletions lang/ja/events/github/label.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

return [
'created' => [
'title' => '💬 <b>New Label</b> ⚠️ - 🦑:repo by :user',
],
'deleted' => [
'title' => '🗑 <b>Label Deleted</b> - 🦑:repo by :user',
],
'edited' => [
'title' => '👷‍♂️🛠️ <b>Label has been edited</b> - 🦑:repo by :user',
'changes' => [
'title' => [
'name' => '📖 <b>Title</b> has been changed',
'from' => '📝 <b>From:</b> :title_from',
'to' => '🏷 <b>To:</b> :title_to',
],
'description' => [
'name' => '📖 <b>Description</b> has been changed',
'from' => '📝 <b>From:</b> :description_from',
'to' => '🏷 <b>To:</b> :description_to',
],
],
],
];
20 changes: 20 additions & 0 deletions lang/ja/events/github/pull_request.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,35 @@

return [
'review' => '👥 Reviewers: ',
'assigned' => [
'title' => '‍👷‍♂️🛠️ <b>Assigned Pull Request</b> - 🦑:repo by :user',
'body' => ':name has been assigned in the pull request <b>:pullRequest</b>',
],
'closed' => [
'title' => ':title - 🦑:repo by :user',
'title_merged' => '✅ <b>Pull Request Merged</b>',
'title_closed' => '🚫 <b>Pull Request Closed</b>',
],
'labeled' => [
'title' => '‍👷‍♂️🛠️ <b>Labeled Pull Request</b> - 🦑:repo by :user',
],
'locked' => [
'title' => '‍👷‍♂️🛠️ <b>Locked Pull Request</b> - 🦑:repo by :user',
],
'opened' => [
'title' => '👷‍♂️🛠️ <b>New Pull Request</b> - 🦑:repo by :user',
],
'reopened' => [
'title' => '👷‍♂️🛠️ <b>Reopened Pull Request</b> - 🦑:repo by :user',
],
'unassigned' => [
'title' => '‍👷‍♂️🛠️ <b>Unassigned Pull Request</b> - 🦑:repo by :user',
'body' => ':name has been unassigned in the pull request <b>:pullRequest</b>',
],
'unlabeled' => [
'title' => '‍👷‍♂️🛠️ <b>Unlabeled Pull Request</b> - 🦑:repo by :user',
],
'unlocked' => [
'title' => '‍👷‍♂️🛠️ <b>Unlocked Pull Request</b> - 🦑:repo by :user',
],
];
25 changes: 25 additions & 0 deletions lang/vi/events/github/label.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

return [
'created' => [
'title' => '💬 <b>New Label</b> ⚠️ - 🦑:repo by :user',
],
'deleted' => [
'title' => '🗑 <b>Label Deleted</b> - 🦑:repo by :user',
],
'edited' => [
'title' => '👷‍♂️🛠️ <b>Label has been edited</b> - 🦑:repo by :user',
'changes' => [
'title' => [
'name' => '📖 <b>Title</b> has been changed',
'from' => '📝 <b>From:</b> :title_from',
'to' => '🏷 <b>To:</b> :title_to',
],
'description' => [
'name' => '📖 <b>Description</b> has been changed',
'from' => '📝 <b>From:</b> :description_from',
'to' => '🏷 <b>To:</b> :description_to',
],
],
],
];
20 changes: 20 additions & 0 deletions lang/vi/events/github/pull_request.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,35 @@

return [
'review' => '👥 Reviewers: ',
'assigned' => [
'title' => '‍👷‍♂️🛠️ <b>Assigned Pull Request</b> - 🦑:repo by :user',
'body' => ':name has been assigned in the pull request <b>:pullRequest</b>',
],
'closed' => [
'title' => ':title - 🦑:repo by :user',
'title_merged' => '✅ <b>Pull Request Merged</b>',
'title_closed' => '🚫 <b>Pull Request Closed</b>',
],
'labeled' => [
'title' => '‍👷‍♂️🛠️ <b>Labeled Pull Request</b> - 🦑:repo by :user',
],
'locked' => [
'title' => '‍👷‍♂️🛠️ <b>Locked Pull Request</b> - 🦑:repo by :user',
],
'opened' => [
'title' => '👷‍♂️🛠️ <b>New Pull Request</b> - 🦑:repo by :user',
],
'reopened' => [
'title' => '👷‍♂️🛠️ <b>Reopened Pull Request</b> - 🦑:repo by :user',
],
'unassigned' => [
'title' => '‍👷‍♂️🛠️ <b>Unassigned Pull Request</b> - 🦑:repo by :user',
'body' => ':name has been unassigned in the pull request <b>:pullRequest</b>',
],
'unlabeled' => [
'title' => '‍👷‍♂️🛠️ <b>Unlabeled Pull Request</b> - 🦑:repo by :user',
],
'unlocked' => [
'title' => '‍👷‍♂️🛠️ <b>Unlocked Pull Request</b> - 🦑:repo by :user',
],
];
12 changes: 8 additions & 4 deletions resources/views/events/github/issue_comment/created.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
$issue = $payload->issue;
?>

@if(empty($issue->pull_request))
{!! __('tg-notifier::events/github/issue_comment.created.title', [
'issue' => "<a href='$issue->html_url'>{$payload->repository->full_name}#$issue->number</a>",
'user' => "<a href='{$issue->user->html_url}'>@{$issue->user->login}</a>"
]
) !!}
'issue' => "<a href='$issue->html_url'>{$payload->repository->full_name}#$issue->number</a>",
'user' => "<a href='{$issue->user->html_url}'>@{$issue->user->login}</a>"
]
) !!}

📢 <b>{{ $issue->title }}</b>

@include('tg-notifier::events.shared.partials.github._assignees', compact('payload', 'event'))
@include('tg-notifier::events.shared.partials.github._body', compact('payload', 'event'))
@else
{{ config('telegram-git-notifier.view.ignore-message') }}
@endif
4 changes: 4 additions & 0 deletions resources/views/events/github/issue_comment/deleted.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
$issue = $payload->issue;
?>

@if(empty($issue->pull_request))
{!! __('tg-notifier::events/github/issue_comment.deleted.title', [
'issue' => "<a href='$issue->html_url'>{$payload->repository->full_name}#$issue->number</a>",
'user' => "<a href='{$issue->user->html_url}'>@{$issue->user->login}</a>"
Expand All @@ -17,3 +18,6 @@

@include('tg-notifier::events.shared.partials.github._assignees', compact('payload', 'event'))
@include('tg-notifier::events.shared.partials.github._body', compact('payload', 'event'))
@else
{{ config('telegram-git-notifier.view.ignore-message') }}
@endif
4 changes: 4 additions & 0 deletions resources/views/events/github/issue_comment/edited.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
$issue = $payload->issue;
?>

@if(empty($issue->pull_request))
{!! __('tg-notifier::events/github/issue_comment.edited.title', [
'issue' => "<a href='$issue->html_url'>{$payload->repository->full_name}#$issue->number</a>",
'user' => "<a href='{$issue->user->html_url}'>@{$issue->user->login}</a>"
Expand All @@ -17,3 +18,6 @@

@include('tg-notifier::events.shared.partials.github._assignees', compact('payload', 'event'))
@include('tg-notifier::events.shared.partials.github._body', compact('payload', 'event'))
@else
{{ config('telegram-git-notifier.view.ignore-message') }}
@endif
17 changes: 17 additions & 0 deletions resources/views/events/github/label/created.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/**
* @var $payload object
*/
$label = $payload->label;
$description = strlen($label->description) > 50 ? $label->description : substr($label->description, 0, 50).'...';
?>

{!! __('tg-notifier::events/github/label.created.title', [
'repo' => "<a href='{$payload->repository->html_url}'>{$payload->repository->full_name}</a>",
'user' => "<a href='{$payload->sender->html_url}'>@{$payload->sender->login}</a>",
]
) !!}

📢 <b>{{ $payload->label->name }}</b>
{{ $description }}
13 changes: 13 additions & 0 deletions resources/views/events/github/label/deleted.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* @var $payload object
*/
?>

{!! __('tg-notifier::events/github/label.deleted.title', [
'repo' => "<a href='{$payload->repository->html_url}'>{$payload->repository->full_name}</a>",
'user' => "<a href='{$payload->sender->html_url}'>@{$payload->sender->login}</a>",
]
) !!}

📢 <b>{{ $payload->label->name }}</b>
34 changes: 34 additions & 0 deletions resources/views/events/github/label/edited.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* @var $payload object
*/
$changes = $payload->changes;
$label = $payload->label;
$description = strlen($label->description) < 50 ? $label->description : substr($label->description, 0, 50).'...';
if (isset($changes->description->from)) {
$description_changes = strlen($changes->description->from) < 50 ? $changes->description->from : substr($changes->description->from, 0, 50).'...';
}
?>

{!! __('tg-notifier::events/github/label.edited.title', [
'repo' => "<a href='{$payload->repository->html_url}'>{$payload->repository->full_name}</a>",
'user' => "<a href='{$payload->sender->html_url}'>@{$payload->sender->login}</a>",
]
) !!}

@if(isset($changes->name->from))
{!! __('tg-notifier::events/github/label.edited.changes.title.name') !!}
{!! __('tg-notifier::events/github/label.edited.changes.title.from', ['title_from' => $payload->changes->name->from]) !!}
{!! __('tg-notifier::events/github/label.edited.changes.title.to', ['title_to' => $payload->label->name]) !!}
@else
📢 <b>{{ $label->name }}</b>
@endif

@if(isset($changes->description->from))
{!! __('tg-notifier::events/github/label.edited.changes.description.name') !!}
{!! __('tg-notifier::events/github/label.edited.changes.description.from', ['description_from' => $description_changes]) !!}
{!! __('tg-notifier::events/github/label.edited.changes.description.to', ['description_to' => $description]) !!}
@else
{{ $description }}
@endif
19 changes: 19 additions & 0 deletions resources/views/events/github/pull_request/assigned.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* @var $payload object
*/
$pull_request = $payload->pull_request;
?>

{!! __('tg-notifier::events/github/pull_request.assigned.title', [
'repo' => "<a href='$pull_request->html_url'>{$payload->repository->full_name}#$pull_request->number</a>",
'user' => "<a href='{$pull_request->user->html_url}'>@{$pull_request->user->login}</a>",
]
) !!}

{!! __('tg-notifier::events/github/pull_request.assigned.body', [
'name' => "<a href='{$payload->assignee->html_url}'>@{$payload->assignee->login}</a>",
'pullRequest' => "$pull_request->title",
]
) !!}
Loading

0 comments on commit f8849bf

Please sign in to comment.