-
-
Notifications
You must be signed in to change notification settings - Fork 47
Add support for images in media search #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ltctceplrm
wants to merge
37
commits into
mProjectsCode:master
Choose a base branch
from
ltctceplrm:image2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
3988bf4
Add support for images in media search
ltctceplrm e4a8e2a
Added images to season search selection
ltctceplrm 47a78d5
Ran prettier
ltctceplrm 68e781e
Normalize css between files
ltctceplrm f8939d2
Update styles.css
ltctceplrm c78f7f9
Different rate limit for MALAPI and MALAPIManga
ltctceplrm 33a5c9c
Refactor thumbnails to js instead of hardcoded css
ltctceplrm 2ba460d
Ran prettier
ltctceplrm 3fd393f
Merge branch 'master' into image2
ltctceplrm 0bc0c88
Revert "Merge branch 'master' into image2"
ltctceplrm fe5fdb9
migrate to secret storage and other improvements
mProjectsCode d0118e5
fix merge
mProjectsCode b41402b
add unrelease changelog section
mProjectsCode e4cefe3
[auto] bump version to `0.8.0-canary.20260406T152025`
mProjectsCode c6be7de
fix scripts
mProjectsCode f55e488
[auto] bump version to `0.8.0-canary.20260406T152358`
mProjectsCode 3721e14
fix scripts 2
mProjectsCode 260cd83
[auto] bump version to `0.8.0-canary.20260406T152718`
mProjectsCode ec33974
add obsidian eslint plugin, solve major issues
mProjectsCode e058bcb
cleanup of new result code
mProjectsCode 1405a05
more changes to modal flow, fixes some issues I hope
mProjectsCode 1bf7b47
another cleanup pass
mProjectsCode 1f31acd
add repo config
mProjectsCode 2683ea7
update deps
mProjectsCode 254f7af
fix config
mProjectsCode 74e11d5
fix errors
mProjectsCode ad2bba4
[auto] bump version to `0.8.0-canary.20260602T115558`
mProjectsCode f3ac8ac
remove solid; rework season search
mProjectsCode 27b320e
add check pr workflow
mProjectsCode 2e0efba
Merge branch 'master' into image2
ltctceplrm 213268d
Fix casing + ran prettier
ltctceplrm 176bf25
Fixed error when image url can't be downloaded
ltctceplrm 7e32ea4
Improve rate limit delay with auto-fetcher
ltctceplrm 01945b0
Move css to styles.css (WIP)
ltctceplrm 417e2ed
normalized css classes + added missing return type on function
ltctceplrm 6a4913a
Replace emoji with setIcon
ltctceplrm 1cfeca5
Several small improvements
ltctceplrm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,4 +22,4 @@ jobs: | |
|
|
||
| - name: Run Checks | ||
| run: | | ||
| bun run check | ||
| bun run check | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| import { setIcon } from 'obsidian'; | ||
|
|
||
| export interface MediaItemComponentOptions { | ||
| imageUrl?: string; | ||
| imageAlt?: string; | ||
| onImageError?: () => void; | ||
| onImageLoad?: () => void; | ||
| renderContent: (contentEl: HTMLElement) => void; | ||
| } | ||
|
|
||
| export class MediaItemComponent { | ||
| private container: HTMLElement; | ||
| private thumbEl!: HTMLElement; | ||
| private contentEl!: HTMLElement; | ||
| private imgEl: HTMLImageElement | undefined; | ||
| private options: MediaItemComponentOptions; | ||
|
|
||
| constructor(container: HTMLElement, options: MediaItemComponentOptions) { | ||
| this.container = container; | ||
| this.options = options; | ||
|
|
||
| this.setup(); | ||
| } | ||
|
|
||
| private setup(): void { | ||
| // Set container layout | ||
| this.container.addClass('media-db-plugin-select-media-item-component'); | ||
|
|
||
| // Create thumbnail | ||
| this.thumbEl = this.container.createDiv({ cls: 'media-db-plugin-select-media-item-thumb' }); | ||
|
|
||
| // Create content area | ||
| this.contentEl = this.container.createDiv({ cls: 'media-db-plugin-select-media-item-content' }); | ||
|
|
||
| // Render custom content | ||
| this.options.renderContent(this.contentEl); | ||
|
|
||
| // Setup image if provided | ||
| if (this.options.imageUrl) { | ||
| this.loadImage(this.options.imageUrl); | ||
| } else { | ||
| this.showPlaceholder(); | ||
| } | ||
| } | ||
|
|
||
| private loadImage(url: string): void { | ||
| if (!this.imgEl) { | ||
| this.imgEl = activeDocument.createElement('img'); | ||
| this.imgEl.loading = 'lazy'; | ||
| this.imgEl.alt = this.options.imageAlt ?? 'Media item'; | ||
| this.imgEl.className = 'media-db-plugin-select-media-item-image'; | ||
|
|
||
| this.imgEl.onerror = (): void => { | ||
| this.showPlaceholder(); | ||
| this.options.onImageError?.(); | ||
| }; | ||
|
|
||
| this.imgEl.onload = (): void => { | ||
| this.options.onImageLoad?.(); | ||
| }; | ||
|
|
||
| this.thumbEl.empty(); | ||
| this.thumbEl.appendChild(this.imgEl); | ||
| } | ||
|
|
||
| this.imgEl.src = url; | ||
| } | ||
|
|
||
| private showPlaceholder(): void { | ||
| this.thumbEl.empty(); | ||
| const iconEl = this.thumbEl.createDiv('icon'); | ||
| setIcon(iconEl, 'image'); | ||
| iconEl.className = 'media-db-plugin-select-media-item-placeholder'; | ||
| } | ||
|
|
||
| public updateImage(url: string | undefined): void { | ||
| if (url && url !== 'NSFW') { | ||
| if (!String(url).includes('null')) { | ||
| this.loadImage(url); | ||
| } else { | ||
| this.showPlaceholder(); | ||
| } | ||
| } else if (url === 'NSFW') { | ||
| this.thumbEl.empty(); | ||
| this.thumbEl.createEl('span', { text: 'NSFW', cls: 'media-db-plugin-select-media-item-placeholder' }); | ||
| } else { | ||
| this.showPlaceholder(); | ||
| } | ||
| } | ||
|
|
||
| public getContentElement(): HTMLElement { | ||
| return this.contentEl; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.