Skip to content

Commit

Permalink
Added stackExchange source
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamkrishnar committed Aug 10, 2020
1 parent afdd37c commit 0a6f771
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ This workflow has additional options that you can use to customize it for your u
| `disable_sort` | `false` | Disables the sorting of list based on publish date | No |
| `template` | `default` | Allows you to change the structure of the posts list by using the `$title`, `$url` and `$newline` variables. By default this workflow uses markdown list format to render the posts, you can override this behaviour using this option. Eg: `[$title]($url) ` will give you a space separated list of posts | No |
| `tag_post_pre_newline` | `true` if you are not using **template** option | Allows you to insert a newline before the closing tag and after the opening tag when using the template option if needed, for better formatting | No |
| `filter_comments` | `medium,stackoverflow/Comment by $author/` | Comma separated list of platforms you want to enable the comment filter. Available filters: <ul><li>`medium`: Allow you to filter out the medium comments</li><li>`stackoverflow/Comment by $author/`: Allow you to filter out the StackOverflow comment. Argument to this filter is optional, it defaults to 'Comment by $author'. If you use any other language other than English on StackOverflow, you can use this argument to customize it. See [#16](https://github.com/gautamkrishnar/blog-post-workflow/issues/16) for more info.</li></ul> | No |
| `filter_comments` | `medium,stackoverflow/Comment by $author/,stackexchange/Comment by $author/` | Comma separated list of platforms you want to enable the comment filter. Available filters: <ul><li>`medium`: Allow you to filter out the medium comments</li><li>`stackoverflow/Comment by $author/`: Allow you to filter out the StackOverflow comments. Argument to this filter is optional, it defaults to 'Comment by $author'. If you use any language other than English on StackOverflow, you can use this argument to customize it. See [#16](https://github.com/gautamkrishnar/blog-post-workflow/issues/16) for more info.</li><li>`stackexchange`: Allow you to filter out the StackExchange comments. Argument to this filter follows same format as `stackoverflow` filter's argument.</li></ul> | No |
| `commit_message` | `Updated with the latest blog posts` | Allows you to customize the commit message | No |
| `committer_username` | `blog-post-bot` | Allows you to customize the committer username | No |
| `committer_email` | `blog-post-bot@example.com` | Allows you to customize the committer email | No |
Expand Down Expand Up @@ -97,6 +97,7 @@ Following are the list of some popular blogging platforms and their RSS feed url
| [Wordpress](https://wordpress.org/) | `https://www.example.com/feed/` | Replace wih your own blog url | https://www.gautamkrishnar.com/feed/ |
| [Medium](https://medium.com/) | `https://medium.com/feed/@username` | Replace @username with your medium username | https://medium.com/feed/@khaosdoctor |
| [Stackoverflow](https://stackoverflow.com/) | `https://stackoverflow.com/feeds/user/userid` | Replace wih your StackOverflow [UserId](https://meta.stackexchange.com/questions/98771/what-is-my-user-id/111130#111130) | https://stackoverflow.com/feeds/user/5283532 |
| [StackExchange](https://stackexchange.com/) | `https://subdomain.stackexchange.com/feeds/user/userid` | Replace wih your StackExchange [UserId](https://meta.stackexchange.com/questions/98771/what-is-my-user-id/111130#111130) and sub-domain | https://devops.stackexchange.com/feeds/user/15 |
| [Ghost](https://ghost.org/) | `https://www.example.com/rss/` | Replace wih your own blog url | https://blog.codinghorror.com/rss/ |
| [Drupal](https://www.drupal.org/) | `https://www.example.com/rss.xml` | Replace wih your own blog url | https://www.arsenal.com/rss.xml |
| [Youtube Playlists](https://www.youtube.com) | `https://www.youtube.com/feeds/videos.xml?playlist_id=playlistId` | Replace `playlistId` with your own Youtube playlist id | https://www.youtube.com/feeds/videos.xml?playlist_id=PLJNqgDLpd5E69Kc664st4j7727sbzyx0X |
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ inputs:
required: false
filter_comments:
description: "Comma separated list of platforms you want to enable the comment filter"
default: "stackoverflow,medium"
default: "medium,stackoverflow/Comment by $author/,stackexchange/Comment by $author/"
required: false
tag_post_pre_newline:
description: "Inserts newline before the closing tag and after the opening tag when using the template option, for formatting"
Expand Down
11 changes: 9 additions & 2 deletions blog-post-workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ const TOTAL_POST_COUNT = Number.parseInt(core.getInput('max_post_count'));
const README_FILE_PATH = core.getInput('readme_path');
const GITHUB_TOKEN = core.getInput('gh_token');
const FILTER_PARAMS = {
stackoverflow: "Comment by $author"
stackoverflow: "Comment by $author",
stackexchange: "Comment by $author",
};

/**
Expand All @@ -111,7 +112,7 @@ const COMMENT_FILTERS = core
.split(',')
.map((item)=>{
const str = item.trim();
if (str.startsWith('stackoverflow')) {
if (str.startsWith('stackoverflow') || str.startsWith('stackexchange')) {
return updateAndParseParams(item);
} else {
return str;
Expand Down Expand Up @@ -142,6 +143,11 @@ const ignoreStackOverflowComments = (item) => !(COMMENT_FILTERS.indexOf('stackov
item.link.includes('stackoverflow.com') &&
item.title.startsWith(FILTER_PARAMS.stackoverflow.replace(/\$author/g, item.author)));

// filters out stackOverflow comments (#16)
const ignoreStackExchangeComments = (item) => !(COMMENT_FILTERS.indexOf('stackexchange') !== -1 &&
item.link.includes('stackexchange.com') &&
item.title.startsWith(FILTER_PARAMS.stackexchange.replace(/\$author/g, item.author)));

feedList.forEach((siteUrl) => {
runnerNameArray.push(siteUrl);
promiseArray.push(new Promise((resolve, reject) => {
Expand All @@ -153,6 +159,7 @@ feedList.forEach((siteUrl) => {
const posts = responsePosts
.filter(ignoreMediumComments)
.filter(ignoreStackOverflowComments)
.filter(ignoreStackExchangeComments)
.map((item) => {
// Validating keys to avoid errors
if (!item.pubDate) {
Expand Down

0 comments on commit 0a6f771

Please sign in to comment.