Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
### Before you begin

- I understand my contributions may be rejected for any reason
- I understand my contributions are for the benefit of Derpibooru and/or the Philomena software
- I understand my contributions are for the benefit of the Philomena software
- I understand my contributions may be used by any and all site operators using the Philomena software
- I understand my contributions are licensed under the GNU AGPLv3

* [ ] I understand all of the above
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Prettier doesn't know about the ||syntax|| and produces garbage output.
priv/repo/seeds/data/pages/markdown.md
11 changes: 11 additions & 0 deletions assets/css/options/colored-logo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
i.favicon-home {
position: relative;
top: 2px;
background-image: unset !important;
background-color: var(--logo-color);
-webkit-mask-image: url("/favicon.svg");
mask-image: url("/favicon.svg");
mask-size: contain;
mask-repeat: no-repeat;
mask-position: center;
}
2 changes: 1 addition & 1 deletion assets/css/themes/dark-blue.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ $autocomplete-history-color: #79afe4;
*/

:root {
--keep: #111111;
--logo-color: #73d6ed;
}
2 changes: 1 addition & 1 deletion assets/css/themes/dark-gray.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ $autocomplete-history-color: #9baab5;
*/

:root {
--keep: #888888;
--logo-color: #9194a5;
}
2 changes: 1 addition & 1 deletion assets/css/themes/dark-green.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ $autocomplete-history-color: #11cf69;
*/

:root {
--keep: #333333;
--logo-color: #0fc84d;
}
1 change: 1 addition & 0 deletions assets/css/themes/dark-orange.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@ $autocomplete-history-color: #eb6d2e;

:root {
--comment-color: #b099dd;
--logo-color: #fb6115;
}
2 changes: 1 addition & 1 deletion assets/css/themes/dark-pink.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ $autocomplete-history-color: #f0509b;
*/

:root {
--keep: #555555;
--logo-color: #e357c5;
}
2 changes: 1 addition & 1 deletion assets/css/themes/dark-purple.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ $autocomplete-history-color: #b577eb;
*/

:root {
--keep: #666666;
--logo-color: #9a91d9;
}
2 changes: 1 addition & 1 deletion assets/css/themes/dark-red.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ $autocomplete-history-color: #d2d207;
*/

:root {
--keep: #777777;
--logo-color: #ff8080;
}
2 changes: 1 addition & 1 deletion assets/css/themes/dark-teal.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ $autocomplete-history-color: #0ebcbf;
*/

:root {
--keep: #222222;
--logo-color: #49d1ca;
}
2 changes: 1 addition & 1 deletion assets/css/themes/dark-yellow.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ $autocomplete-history-color: #e9c600;
*/

:root {
--keep: #999999;
--logo-color: #fbc115;
}
2 changes: 1 addition & 1 deletion assets/css/themes/light-blue.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ $autocomplete-history-color: #419cd9;
*/

:root {
--keep: #000000;
--logo-color: #73d6ed;
}
1 change: 1 addition & 0 deletions assets/css/themes/light-gray.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,5 @@ $autocomplete-history-color: #3e7da1;
--media-box-color: hsl(from $base-color h calc(s - 26) calc(l + 20));
--media-box-hover-color: hsl(from $base-color h calc(s - 20) calc(l + 14));
--background-odd-color: #eaeaea;
--logo-color: #d4d7e9;
}
1 change: 1 addition & 0 deletions assets/css/themes/light-green.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ $autocomplete-history-color: #2ca052;
:root {
--comment-color: #9273d0;
--background-odd-color: #e6f3ea;
--logo-color: #0ef059;
}
1 change: 1 addition & 0 deletions assets/css/themes/light-orange.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ $autocomplete-history-color: #d97441;

:root {
--comment-color: #9273d0;
--logo-color: #ffad98;
}
2 changes: 1 addition & 1 deletion assets/css/themes/light-pink.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ $autocomplete-history-color: #d941c0;
*/

:root {
--keep: #dddddd;
--logo-color: #f6b0c7;
}
2 changes: 1 addition & 1 deletion assets/css/themes/light-purple.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ $autocomplete-history-color: #9241d9;
*/

:root {
--keep: #eeeeee;
--logo-color: #b6a0f3;
}
1 change: 1 addition & 0 deletions assets/css/themes/light-red.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ $autocomplete-history-color: #d94141;
:root {
--header-admin-color: hsl(from $foreground-color h s calc(l + 60));
--header-admin-hover-color: hsl(from $foreground-color h s calc(l + 50));
--logo-color: #ff8080;
}
1 change: 1 addition & 0 deletions assets/css/themes/light-teal.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ $autocomplete-history-color: #1098a2;

:root {
--background-odd-color: #e2f1f1;
--logo-color: #a0f3ef;
}
1 change: 1 addition & 0 deletions assets/css/themes/light-yellow.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ $autocomplete-history-color: #8e7e06;
:root {
--comment-color: #9273d0;
--background-odd-color: #f5efde;
--logo-color: #fbc115;
}
2 changes: 1 addition & 1 deletion assets/js/__tests__/interactions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ describe('interactions', () => {
setupInteractions();

expect(downvote.classList.contains('disabled')).toBe(true);
expect(downvote.getAttribute('title')).toMatch('Neigh!');
expect(downvote.getAttribute('title')).toMatch('Downvote');
});

it('displayInteractionSet handles voted with no up/down value (no class changes)', () => {
Expand Down
4 changes: 4 additions & 0 deletions assets/js/booru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ export interface BooruObject {
* Fancy tag setting for editing images.
*/
fancyTagEdit: boolean;
/**
* Minimum number of tags required on upload
*/
minimumTags: number;
}

declare global {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface CacheRecord {
value: InteractionValue;
}

const spoilerDownvoteMsg = 'Neigh! - Remove spoilered tags from your filters to downvote from thumbnails';
const spoilerDownvoteMsg = 'Downvote - Remove spoilered tags from your filters to downvote from thumbnails';

/**
* Quick helper function to less verbosely iterate a QSA
Expand Down
22 changes: 11 additions & 11 deletions assets/js/query/__tests__/lex.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ describe('Lexical analysis', () => {
});

it('should prioritize AND over OR', () => {
const array = generateLexArray('safe OR solo AND fluttershy', parseTerm);
expect(terms).toEqual(['safe', 'solo', 'fluttershy']);
const array = generateLexArray('safe OR solo AND alice', parseTerm);
expect(terms).toEqual(['safe', 'solo', 'alice']);
expect(array).toEqual([noMatch, noMatch, noMatch, 'and_op', 'or_op']);
});

it('should override ordering when using parenthetical expressions', () => {
const array = generateLexArray('(safe OR solo) AND fluttershy', parseTerm);
expect(terms).toEqual(['safe', 'solo', 'fluttershy']);
const array = generateLexArray('(safe OR solo) AND alice', parseTerm);
expect(terms).toEqual(['safe', 'solo', 'alice']);
expect(fuzzes).toEqual([0, 0, 0]);
expect(boosts).toEqual([1, 1, 1]);
expect(array).toEqual([noMatch, noMatch, 'or_op', noMatch, 'and_op']);
Expand Down Expand Up @@ -153,25 +153,25 @@ describe('Lexical analysis', () => {
});

it('should allow extra spaces in terms', () => {
const array = generateLexArray('twilight sparkle', parseTerm);
expect(terms).toEqual(['twilight sparkle']);
const array = generateLexArray('robin hood', parseTerm);
expect(terms).toEqual(['robin hood']);
expect(array).toEqual([noMatch]);
});

it('should collapse consecutive AND expressions', () => {
const array = generateLexArray('safe AND solo AND fluttershy AND applejack', parseTerm);
expect(terms).toEqual(['safe', 'solo', 'fluttershy', 'applejack']);
const array = generateLexArray('safe AND solo AND alice AND sofia', parseTerm);
expect(terms).toEqual(['safe', 'solo', 'alice', 'sofia']);
expect(array).toEqual([noMatch, noMatch, 'and_op', noMatch, 'and_op', noMatch, 'and_op']);
});

it('should collapse consecutive OR expressions', () => {
const array = generateLexArray('safe OR solo OR fluttershy OR applejack', parseTerm);
expect(terms).toEqual(['safe', 'solo', 'fluttershy', 'applejack']);
const array = generateLexArray('safe OR solo OR alice OR sofia', parseTerm);
expect(terms).toEqual(['safe', 'solo', 'alice', 'sofia']);
expect(array).toEqual([noMatch, noMatch, 'or_op', noMatch, 'or_op', noMatch, 'or_op']);
});

it('should mark error on mismatched parentheses', () => {
expect(() => generateLexArray('(safe OR solo AND fluttershy', parseTerm)).toThrow('Mismatched parentheses.');
expect(() => generateLexArray('(safe OR solo AND alice', parseTerm)).toThrow('Mismatched parentheses.');
// expect(() => generateLexArray(')bad', parseTerm).error).toThrow('Mismatched parentheses.');
});
});
22 changes: 11 additions & 11 deletions assets/js/query/__tests__/literal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ describe('Literal field parsing', () => {
});

it('should handle fuzzy matching based on normalized edit distance', () => {
const matcher = makeLiteralMatcher('fluttersho', 0.8, false);
expect(matcher('fluttershy', 'tags', 0)).toBe(true);
expect(matcher('rarity', 'tags', 0)).toBe(false);
const matcher = makeLiteralMatcher('materialization', 0.8, false);
expect(matcher('materialisation', 'tags', 0)).toBe(true);
expect(matcher('quantum entanglement', 'tags', 0)).toBe(false);
});

it('should handle fuzzy matching based on raw edit distance', () => {
const matcher = makeLiteralMatcher('fluttersho', 1, false);
expect(matcher('fluttershy', 'tags', 0)).toBe(true);
expect(matcher('rarity', 'tags', 0)).toBe(false);
const matcher = makeLiteralMatcher('materialization', 1, false);
expect(matcher('materialisation', 'tags', 0)).toBe(true);
expect(matcher('quantum entanglement', 'tags', 0)).toBe(false);
});

it('should handle wildcard matching', () => {
const matcher = makeLiteralMatcher('fl?tter*', 0, true);
expect(matcher('fluttershy', 'tags', 0)).toBe(true);
expect(matcher('flitter', 'tags', 0)).toBe(true);
expect(matcher('rainbow dash', 'tags', 0)).toBe(false);
expect(matcher('gentle flutter', 'tags', 0)).toBe(false);
const matcher = makeLiteralMatcher('ma?e*', 0, true);
expect(matcher('mane', 'tags', 0)).toBe(true);
expect(matcher('materialization', 'tags', 0)).toBe(true);
expect(matcher('alice', 'tags', 0)).toBe(false);
expect(matcher('nightmare', 'tags', 0)).toBe(false);
});
});
14 changes: 7 additions & 7 deletions assets/js/query/__tests__/parse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ describe('Semantic analysis', () => {
beforeAll(() => {
const e0 = document.createElement('div');
e0.setAttribute(termSpaceToImageField.id, '0');
e0.setAttribute(termSpaceToImageField.tags, 'safe, solo, fluttershy');
e0.setAttribute(termSpaceToImageField.tags, 'safe, solo, alice');

const e1 = document.createElement('div');
e1.setAttribute(termSpaceToImageField.id, '1');
e1.setAttribute(termSpaceToImageField.tags, 'suggestive, solo, fluttershy');
e1.setAttribute(termSpaceToImageField.tags, 'suggestive, solo, alice');

const e2 = document.createElement('div');
e2.setAttribute(termSpaceToImageField.id, '2');
e2.setAttribute(termSpaceToImageField.tags, 'suggestive, fluttershy, twilight sparkle');
e2.setAttribute(termSpaceToImageField.tags, 'suggestive, alice, robin hood');

documents = [e0, e1, e2];
});

it('should match single term expressions', () => {
const tokens = generateLexArray('fluttershy', parseWithDefaultMatcher);
const tokens = generateLexArray('alice', parseWithDefaultMatcher);
const matcher = parseTokens(tokens);

expect(matcher(documents[0])).toBe(true);
Expand All @@ -37,7 +37,7 @@ describe('Semantic analysis', () => {
});

it('should match AND expressions', () => {
const tokens = generateLexArray('fluttershy,solo', parseWithDefaultMatcher);
const tokens = generateLexArray('alice,solo', parseWithDefaultMatcher);
const matcher = parseTokens(tokens);

expect(matcher(documents[0])).toBe(true);
Expand All @@ -46,7 +46,7 @@ describe('Semantic analysis', () => {
});

it('should match OR expressions', () => {
const tokens = generateLexArray('suggestive || twilight sparkle', parseWithDefaultMatcher);
const tokens = generateLexArray('suggestive || robin hood', parseWithDefaultMatcher);
const matcher = parseTokens(tokens);

expect(matcher(documents[0])).toBe(false);
Expand All @@ -55,7 +55,7 @@ describe('Semantic analysis', () => {
});

it('should match NOT expressions', () => {
const tokens = generateLexArray('NOT twilight sparkle', parseWithDefaultMatcher);
const tokens = generateLexArray('NOT robin hood', parseWithDefaultMatcher);
const matcher = parseTokens(tokens);

expect(matcher(documents[0])).toBe(true);
Expand Down
4 changes: 2 additions & 2 deletions assets/js/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ export function setupImageUpload() {
errors.push('Tag input may not contain any other rating if safe');
}

if (tagsArr.length < 3) {
errors.push('Tag input must contain at least 3 tags');
if (tagsArr.length < window.booru.minimumTags) {
errors.push(`Tag input must contain at least ${window.booru.minimumTags} tags`);
}

errors.forEach(msg => createTagError(msg));
Expand Down
10 changes: 0 additions & 10 deletions assets/static/opensearch.xml

This file was deleted.

Loading
Loading