-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #406 from linear-b/is-gitstream-user
Create isFlaggedUser plugin and new publishing materials for gitStream plugins.
- Loading branch information
Showing
11 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
title: gitStream Plugins | ||
description: Implement custom gitStream filter functions with JavaScript. | ||
--- | ||
|
||
JavaScript plugins that enable custom filter functions for gitStream. To learn how to use these examples, read our [guide on how to use gitStream plugins](/custom-filters). | ||
|
||
--8<-- "plugins/filters/isFlaggedUser/README.md" | ||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{{>deprecated~}} | ||
{{>description~}} | ||
{{>summary~}} | ||
{{>augments~}} | ||
{{>implements~}} | ||
{{>mixes~}} | ||
{{>default~}} | ||
{{>chainable~}} | ||
{{>overrides~}} | ||
{{>returns~}} | ||
{{>category~}} | ||
{{>throws~}} | ||
{{>fires~}} | ||
{{>this~}} | ||
{{>access~}} | ||
{{>readOnly~}} | ||
{{>requires~}} | ||
{{>customTags~}} | ||
{{>see~}} | ||
{{>since~}} | ||
{{>version~}} | ||
{{>authors~}} | ||
{{>license~}} | ||
{{>copyright~}} | ||
{{>todo~}} | ||
{{>params~}} | ||
{{>properties~}} | ||
{{>examples~}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{{#if virtual}}*{{/if}}{{#with (parentObject)}}{{#if virtual}}*{{/if~}}{{/with~}} | ||
{{#if name}}{{#sig~}} | ||
{{{@depOpen}~}} | ||
{{{@codeOpen}~}} | ||
{{#if @prefix}}{{@prefix}} {{/if~}} | ||
{{@parent~}} | ||
{{@accessSymbol}}{{#if (isEvent)}}"{{{name}}}"{{else}}{{{escape name}}}{{/if~}} | ||
{{#if @methodSign}}{{#if (isEvent)}} {{@methodSign}}{{else}}{{@methodSign}}{{/if}}{{/if~}} | ||
{{{@codeClose}~}} | ||
{{#if @suffix}} {{@suffix}}{{/if~}} | ||
{{{@depClose}~}} | ||
{{~/sig}}{{/if~}} | ||
{{#if virtual}}*{{/if}}{{#with (parentObject)}}{{#if virtual}}*{{/if~}}{{/with~}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
title: gitStream Plugin - filterName | ||
description: Indicate if a user is included in a specified list. | ||
--- | ||
<!-- | ||
This is a template file for a gitStream plugin README.md files | ||
In a nutshell, the custom filter pages are published under /docs/plugins, and all associated content and examples are imported via associated files inside that directory. | ||
How to use this template. | ||
1. Create a README.md file inside the plugin's directory and copy/paste the content of this file into it. | ||
1. Find a replace the strings below with the appropriate information | ||
Here are the strings to replace | ||
- docs/plugins/filters/standard/filterName/ - change this to match the directory of the plugin. This should match the function exported in the plugin's index.js | ||
- filterName - This should match the function exported in the plugin's index.js | ||
- filter_name - This should match the name of CM example file that is included with the plugin. | ||
--> | ||
|
||
|
||
--8<-- "docs/plugins/filters/standard/filterName/reference.md" | ||
|
||
??? note "Plugin Code: filterName" | ||
```javascript | ||
--8<-- "docs/plugins/filters/standard/filterName/index.js" | ||
``` | ||
<div class="result" markdown> | ||
<span> | ||
</span> | ||
</div> | ||
|
||
|
||
??? example "gitStream CM Example: filterName" | ||
```yaml+jinja | ||
--8<-- "docs/plugins/filters/standard/filterName/filter_name.cm" | ||
``` | ||
<div class="result" markdown> | ||
<span> | ||
</span> | ||
</div> | ||
|
||
[Download Source Code](https://github.com/linear-b/gitstream/tree/main/docs/plugins/filters/standard/filterName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 LinearB | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--8<-- "plugins/filters/isFlaggedUser/reference.md" | ||
|
||
??? note "Plugin Code: isFlaggedUser" | ||
```javascript | ||
--8<-- "plugins/filters/isFlaggedUser/index.js" | ||
``` | ||
<div class="result" markdown> | ||
<span> | ||
</span> | ||
</div> | ||
|
||
|
||
??? example "gitStream CM Example: isFlaggedUser" | ||
```yaml+jinja | ||
--8<-- "plugins/filters/isFlaggedUser/is_flagged_user.cm" | ||
``` | ||
<div class="result" markdown> | ||
<span> | ||
</span> | ||
</div> | ||
|
||
[Download Source Code](https://github.com/linear-b/gitstream/tree/main/plugins/filters/isFlaggedUser) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Add users who you want to add to the flag list. | ||
const flaggedUsers = ["user1", "user2"]; | ||
/** | ||
* @description Returns true if the username that is passed to this function is specified in a predefined list of users. | ||
* This is useful if you want gitStream automations to run only for specified users. | ||
* @module isFlaggedUser | ||
* @param {string} Input - The GitHub username to check. | ||
* @returns {boolean} Returns true if the user is specified in the flaggedUsers list, otherwise false. | ||
* @example {{ pr.author | isFlaggedUser }} | ||
* @license MIT | ||
*/ | ||
function isFlaggedUser(username) { | ||
if (containsString(flaggedUsers, username)) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}; | ||
|
||
function containsString(arr, str) { | ||
return arr.includes(str); | ||
}; | ||
|
||
module.exports = isFlaggedUser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# -*- mode: yaml -*- | ||
|
||
manifest: | ||
version: 1.0 | ||
|
||
automations: | ||
detect_flagged_user: | ||
if: | ||
- {{ pr.author | isFlaggedUser }} | ||
run: | ||
- action: add-comment@v1 | ||
args: | ||
comment: {{ pr.author }} is a gitStream user. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<a name="module_isFlaggedUser"></a> | ||
|
||
## isFlaggedUser | ||
Returns true if the username that is passed to this function is specified in a predefined list of users. | ||
This is useful if you want gitStream automations to run only for specified users. | ||
|
||
**Returns**: <code>boolean</code> - Returns true if the user is specified in the flaggedUsers list, otherwise false. | ||
**License**: MIT | ||
|
||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| Input | <code>string</code> | The GitHub username to check. | | ||
|
||
**Example** | ||
```js | ||
{{ pr.author | isFlaggedUser }} | ||
``` |