Display post resolution (where available)

next
neobooru 2021-12-07 20:17:53 +01:00
parent c59caef23a
commit f4d4cb5615
5 changed files with 26 additions and 4 deletions

View File

@ -12,7 +12,8 @@
"build:dev": "webpack --config webpack.dev.js", "build:dev": "webpack --config webpack.dev.js",
"build-zip": "node scripts/build-zip.js", "build-zip": "node scripts/build-zip.js",
"sign-xpi": "node scripts/sign-xpi.js", "sign-xpi": "node scripts/sign-xpi.js",
"watch": "webpack --watch --config webpack.dev.js" "watch": "webpack --watch --config webpack.dev.js",
"prepare": "npm run build"
}, },
"dependencies": { "dependencies": {
"axios": "^0.23.0", "axios": "^0.23.0",

View File

@ -90,7 +90,7 @@ export default class SzuruWrapper {
return (await this.apiPost("posts/reverse-search", obj)).data; return (await this.apiPost("posts/reverse-search", obj)).data;
} }
static async createFromConfig(siteConfig: SzuruSiteConfig): Promise<SzuruWrapper | null> { static createFromConfig(siteConfig: SzuruSiteConfig): SzuruWrapper | null {
return new SzuruWrapper(siteConfig.domain, siteConfig.username, siteConfig.authToken); return new SzuruWrapper(siteConfig.domain, siteConfig.username, siteConfig.authToken);
} }

View File

@ -35,6 +35,7 @@ export class PostViewModel {
rating: BooruTypes.SafetyRating; rating: BooruTypes.SafetyRating;
source: string | undefined; source: string | undefined;
referrer: string | undefined; referrer: string | undefined;
resolution: [number, number] | undefined;
constructor(post: ScrapedPost) { constructor(post: ScrapedPost) {
this.contentUrl = post.contentUrl; this.contentUrl = post.contentUrl;
@ -45,5 +46,6 @@ export class PostViewModel {
this.referrer = post.referrer; this.referrer = post.referrer;
this.tags = post.tags.map(x => TagViewModel.fromScapedTag(x)); this.tags = post.tags.map(x => TagViewModel.fromScapedTag(x));
this.notes = post.notes; this.notes = post.notes;
this.resolution = post.resolution;
} }
} }

View File

@ -48,6 +48,7 @@ select {
width: 100%; width: 100%;
} }
ul.compact,
.compact-tags { .compact-tags {
list-style-type: none; list-style-type: none;
padding: 0; padding: 0;

View File

@ -18,6 +18,12 @@
<i class="fas fa-cog cursor-pointer" @click="openSettings"></i> <i class="fas fa-cog cursor-pointer" @click="openSettings"></i>
</div> </div>
<div class="section-row">
<ul class="compact">
<li>Resolution: {{ resolutionToString(selectedPost.resolution) }}</li>
</ul>
</div>
<div class="section-row"> <div class="section-row">
<span class="section-label">Safety</span> <span class="section-label">Safety</span>
@ -236,6 +242,12 @@ export default Vue.extend({
// Based on https://stackoverflow.com/a/6316913 // Based on https://stackoverflow.com/a/6316913
return tagName.replace(/\_/g, "_<wbr>"); return tagName.replace(/\_/g, "_<wbr>");
}, },
resolutionToString(resolution: [number, number]) {
if (resolution && resolution.length == 2) {
return resolution[0] + "x" + resolution[1];
}
return "";
},
// Remove tag from post's taglist // Remove tag from post's taglist
removeTag(tag: TagViewModel) { removeTag(tag: TagViewModel) {
if (this.selectedPost) { if (this.selectedPost) {
@ -442,9 +454,11 @@ export default Vue.extend({
if (!this.activeSite) { if (!this.activeSite) {
this.pushError("No szurubooru server configured!"); this.pushError("No szurubooru server configured!");
} else { } else {
this.szuru = await SzuruWrapper.createFromConfig(this.activeSite); this.szuru = SzuruWrapper.createFromConfig(this.activeSite);
} }
console.log("hello")
browser.runtime.onMessage.addListener((cmd: BrowserCommand, sender: Runtime.MessageSender) => { browser.runtime.onMessage.addListener((cmd: BrowserCommand, sender: Runtime.MessageSender) => {
switch (cmd.name) { switch (cmd.name) {
case "push_message": case "push_message":
@ -486,7 +500,7 @@ export default Vue.extend({
); );
// Always call grabPost, even when there is no activeSite // Always call grabPost, even when there is no activeSite
await this.grabPost(); // await this.grabPost();
}, },
}); });
</script> </script>
@ -556,6 +570,10 @@ video {
margin: 0 0 5px 0; margin: 0 0 5px 0;
} }
.section-block {
display: block;
}
.cursor-pointer { .cursor-pointer {
cursor: pointer; cursor: pointer;
} }