Skip to content

Commit

Permalink
Merge pull request #74 from francislavoie/skip-repos
Browse files Browse the repository at this point in the history
  • Loading branch information
musically-ut committed Jul 4, 2021
2 parents a9d2ec5 + 8f18501 commit f192418
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.{html,js,css}]
indent_size = 2
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
9 changes: 9 additions & 0 deletions webext/data/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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

Expand Down Expand Up @@ -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. */
Expand Down
6 changes: 6 additions & 0 deletions webext/options_ui/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,32 @@

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'

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 }, () => {
Expand All @@ -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)
35 changes: 22 additions & 13 deletions webext/options_ui/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,35 @@ <h1 class="ui block header">
</section>

<section class="ui settings basic segment">
<p>Only show message when last commit in base repo is older than?</p>
<div class="ui form">
<div class="ui field">
<div class="ui labeled input">
<div class="ui label">Days:</div>
<input id="days_threshold" class="js-days-threshold" type="number" min="0">
</div>
</div>
<p>Repos on which to skip showing forks (comma, space, or newline separated list)</p>
<div class="ui form">
<div class="ui field">
<label for="skip_repos">Repos to skip:</label>
<textarea id="skip_repos" class="js-skip-repos">
</div>
</div>
</section>

<section class="ui settings basic segment">
<p>Only show message when last commit in base repo is older than?</p>
<div class="ui form">
<div class="ui field">
<div class="ui labeled input">
<div class="ui label">Days:</div>
<input id="days_threshold" class="js-days-threshold" type="number" min="0">
</div>
</div>
</div>
</section>

<section class="ui settings basic segment">
<p>Should the message under the repository name be <span class="emph">indented?</span></p>
<div class="ui form centered-field">
<span class="ui right aligned basic label">do not indent</span>
<div class="ui fitted toggle checkbox js-to-indent to-indent">
<input id="to_indent" type="checkbox">
</div>
<span class="ui left aligned basic label">indent</span>
<span class="ui right aligned basic label">do not indent</span>
<div class="ui fitted toggle checkbox js-to-indent to-indent">
<input id="to_indent" type="checkbox">
</div>
<span class="ui left aligned basic label">indent</span>
</div>
</section>

Expand Down

0 comments on commit f192418

Please sign in to comment.