diff --git a/.editorconfig b/.editorconfig index 2536d66..3e3d710 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,3 +10,6 @@ insert_final_newline = true [*.md] trim_trailing_whitespace = false + +[*.{html,js,css}] +indent_size = 2 diff --git a/README.md b/README.md index 003e0e9..88e256e 100644 --- a/README.md +++ b/README.md @@ -119,3 +119,5 @@ repository. [olso](https://github.com/olso) added an option to set how many days old the last commit on the current repository should be before the forks are shown. [Jorgen1040](https://github.com/Jorgen1040) helped fix a bug about multiple "also forked" messages appearing. + +[francislavoie](https://github.com/francislavoie) implemented a [repo skip list](https://github.com/musically-ut/lovely-forks/pull/74), to not show forks on specific repos. diff --git a/webext/data/contentscript.js b/webext/data/contentscript.js index 9950098..ec8eab2 100644 --- a/webext/data/contentscript.js +++ b/webext/data/contentscript.js @@ -3,6 +3,7 @@ const _logName = 'lovely-forks:' const STAR_THRES_KEY = 'STAR_THRES_KEY' +const SKIP_REPOS_KEY = 'SKIP_REPOS_KEY' const INDENT_KEY = 'INDENT_KEY' const LF_PREF_KEY = 'LF_PREF_KEY' const DAYS_THRES_KEY = 'DAYS_THRES_KEY' @@ -20,6 +21,7 @@ function getPreferences () { x = x[LF_PREF_KEY] || {} pref[STAR_THRES_KEY] = x[STAR_THRES_KEY] || 1 + pref[SKIP_REPOS_KEY] = x[SKIP_REPOS_KEY] || "" pref[DAYS_THRES_KEY] = x[DAYS_THRES_KEY] || 0 pref[INDENT_KEY] = x[INDENT_KEY] || false @@ -218,6 +220,13 @@ function isQuotaExceeded (e) { function processWithData (user, repo, remoteDataStr, selfDataStr, isFreshData, pref) { try { + /* Skip displaying if the repo is in the skip list */ + const skipRepos = pref[SKIP_REPOS_KEY].split(/[\s\n,]+/) + const inSkipList = skipRepos.some(val => val.indexOf(user + "/" + repo) > -1) + if (inSkipList) { + return + } + /* Parse fork data */ /* Can either be just one data element, * or could be the list of all forks. */ diff --git a/webext/options_ui/js/main.js b/webext/options_ui/js/main.js index aaff5d3..876b215 100644 --- a/webext/options_ui/js/main.js +++ b/webext/options_ui/js/main.js @@ -3,6 +3,7 @@ const DEBUG = false const STAR_THRES_KEY = 'STAR_THRES_KEY' +const SKIP_REPOS_KEY = 'SKIP_REPOS_KEY' const INDENT_KEY = 'INDENT_KEY' const LF_PREF_KEY = 'LF_PREF_KEY' const DAYS_THRES_KEY = 'DAYS_THRES_KEY' @@ -10,20 +11,24 @@ const DAYS_THRES_KEY = 'DAYS_THRES_KEY' chrome.storage.local.get(LF_PREF_KEY, x => { x = x[LF_PREF_KEY] || {} const thres = x[STAR_THRES_KEY] || 1 + const skipRepos = x[SKIP_REPOS_KEY] || "" const dayThres = x[DAYS_THRES_KEY] || 0 const indent = x[INDENT_KEY] || false $('.js-star-threshold').val(thres) + $('.js-skip-repos').val(skipRepos) $('.js-days-threshold').val(dayThres) $('.js-to-indent').checkbox(indent ? 'set checked' : 'set unchecked') }) function savePref () { const thres = $('.js-star-threshold').val() || 0 + const skipRepos = $('.js-skip-repos').val() || "" const dayThres = $('.js-days-threshold').val() || 0 const indent = $('.js-to-indent').checkbox('is checked') || false const pref = { [INDENT_KEY]: indent, [STAR_THRES_KEY]: thres, + [SKIP_REPOS_KEY]: skipRepos, [DAYS_THRES_KEY]: dayThres } chrome.storage.local.set({ [LF_PREF_KEY]: pref }, () => { @@ -39,4 +44,5 @@ function savePref () { $('.js-to-indent.ui.checkbox').checkbox({ onChange: savePref }) $('.js-star-threshold').on('change', savePref) +$('.js-skip-repos').on('change', savePref) $('.js-days-threshold').on('change', savePref) diff --git a/webext/options_ui/options.html b/webext/options_ui/options.html index 4f4839f..74bb42e 100644 --- a/webext/options_ui/options.html +++ b/webext/options_ui/options.html @@ -31,26 +31,35 @@
Only show message when last commit in base repo is older than?
-Repos on which to skip showing forks (comma, space, or newline separated list)
+Only show message when last commit in base repo is older than?
+Should the message under the repository name be indented?