forked from Shinonome/dots-hyprland
sidebar: booru: option to disable nsfw by default
This commit is contained in:
@@ -39,6 +39,7 @@ let configOptions = {
|
|||||||
'sidebar': {
|
'sidebar': {
|
||||||
'imageColumns': 2,
|
'imageColumns': 2,
|
||||||
'imageBooruCount': 20,
|
'imageBooruCount': 20,
|
||||||
|
'imageAllowNsfw': false,
|
||||||
},
|
},
|
||||||
'search': {
|
'search': {
|
||||||
'engineBaseUrl': "https://www.google.com/search?q=",
|
'engineBaseUrl': "https://www.google.com/search?q=",
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { MarginRevealer } from '../../.widgethacks/advancedrevealers.js';
|
|||||||
import { setupCursorHover, setupCursorHoverInfo } from '../../.widgetutils/cursorhover.js';
|
import { setupCursorHover, setupCursorHoverInfo } from '../../.widgetutils/cursorhover.js';
|
||||||
import BooruService from '../../../services/booru.js';
|
import BooruService from '../../../services/booru.js';
|
||||||
import { chatEntry } from '../apiwidgets.js';
|
import { chatEntry } from '../apiwidgets.js';
|
||||||
|
import { ConfigToggle } from '../../.commonwidgets/configwidgets.js';
|
||||||
const Grid = Widget.subclass(Gtk.Grid, "AgsGrid");
|
const Grid = Widget.subclass(Gtk.Grid, "AgsGrid");
|
||||||
|
|
||||||
async function getImageViewerApp(preferredApp) {
|
async function getImageViewerApp(preferredApp) {
|
||||||
@@ -85,6 +86,33 @@ const BooruInfo = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const BooruSettings = () => MarginRevealer({
|
||||||
|
transition: 'slide_down',
|
||||||
|
revealChild: true,
|
||||||
|
child: Box({
|
||||||
|
vertical: true,
|
||||||
|
className: 'sidebar-chat-settings',
|
||||||
|
children: [
|
||||||
|
Box({
|
||||||
|
vertical: true,
|
||||||
|
hpack: 'fill',
|
||||||
|
className: 'sidebar-chat-settings-toggles',
|
||||||
|
children: [
|
||||||
|
ConfigToggle({
|
||||||
|
icon: 'menstrual_health',
|
||||||
|
name: 'Lewds',
|
||||||
|
desc: 'Shows naughty stuff when enabled',
|
||||||
|
initValue: BooruService.nsfw,
|
||||||
|
onChange: (self, newValue) => {
|
||||||
|
BooruService.nsfw = newValue;
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
})
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
const booruWelcome = Box({
|
const booruWelcome = Box({
|
||||||
vexpand: true,
|
vexpand: true,
|
||||||
homogeneous: true,
|
homogeneous: true,
|
||||||
@@ -94,6 +122,7 @@ const booruWelcome = Box({
|
|||||||
vertical: true,
|
vertical: true,
|
||||||
children: [
|
children: [
|
||||||
BooruInfo(),
|
BooruInfo(),
|
||||||
|
BooruSettings(),
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const APISERVICES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getWorkingImageSauce = (url) => {
|
const getWorkingImageSauce = (url) => {
|
||||||
if(url.includes('pximg.net')) {
|
if (url.includes('pximg.net')) {
|
||||||
return `https://www.pixiv.net/en/artworks/${url.substring(url.lastIndexOf('/')).replace(/_p\d+\.png$/, '')}`;
|
return `https://www.pixiv.net/en/artworks/${url.substring(url.lastIndexOf('/')).replace(/_p\d+\.png$/, '')}`;
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
@@ -33,6 +33,7 @@ function paramStringFromObj(params) {
|
|||||||
class BooruService extends Service {
|
class BooruService extends Service {
|
||||||
_baseUrl = 'https://yande.re/post.json';
|
_baseUrl = 'https://yande.re/post.json';
|
||||||
_mode = 'yandere';
|
_mode = 'yandere';
|
||||||
|
_nsfw = userOptions.sidebar.imageAllowNsfw;
|
||||||
_responses = [];
|
_responses = [];
|
||||||
_queries = [];
|
_queries = [];
|
||||||
|
|
||||||
@@ -56,6 +57,9 @@ class BooruService extends Service {
|
|||||||
this.emit('clear');
|
this.emit('clear');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get nsfw() { return this._nsfw }
|
||||||
|
set nsfw(value) { this._nsfw = value; }
|
||||||
|
|
||||||
get mode() { return this._mode }
|
get mode() { return this._mode }
|
||||||
set mode(value) {
|
set mode(value) {
|
||||||
this._mode = value;
|
this._mode = value;
|
||||||
@@ -66,7 +70,7 @@ class BooruService extends Service {
|
|||||||
|
|
||||||
async fetch(msg) {
|
async fetch(msg) {
|
||||||
// Init
|
// Init
|
||||||
const userArgs = msg.split(/\s+/);
|
const userArgs = `${msg}${this._nsfw ? '' : ' rating:safe'}`.split(/\s+/);
|
||||||
|
|
||||||
let taglist = [];
|
let taglist = [];
|
||||||
// Construct body/headers
|
// Construct body/headers
|
||||||
|
|||||||
Reference in New Issue
Block a user