Skip to content
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

feat: add cover image edge curl option #119

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

kitschpatrol
Copy link
Contributor

@kitschpatrol kitschpatrol commented Sep 4, 2024

Thanks for this plugin!

This PR adds a new check box to the settings to enable or disable the (rather unfortunate) "page curl" effect that's added by default to the bottom-right of cover images from the Google Books API.

The new setting:

Screenshot 2024-09-03 at 20 44 18 of Obsidian - arabesque - Vault - Obsidian v1 6 7@2x

Sample cover with setting enabled:

Sample cover with setting disabled:

The default is "enabled" so as not to change the plugin's existing behavior. (Though I'd argue that "disabled" might be a better default since the effect is so middling.)

The PR includes new tests for the feature, and implements conditional rendering for the option in the settings page since it does not apply when Naver is the API source.

Implementation notes:

  • The implementation for conditional rendering of the settings entry is a bit verbose, but matches the plugin's existing approach.

  • The plugin's existing settings menu item titles are inconsistently cased, and don't follow the Obsidian style guide, but I followed the "Title Case" precedent used by other image-related settings.

  • The new setting is ordered before the "Enable Cover Image Save" setting since it applies to the template values of both {{coverUrl}} and {{localCoverImage}}.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added a new "Show Cover Images in Search" option in plugin settings for displaying cover images alongside book suggestions.
    • Introduced "Cover Image Saving" feature to automatically download and save book cover images into the Obsidian vault.
    • Added "Cover Image Edge Curl" toggle in plugin settings to control the page curl effect for cover images.
  • Bug Fixes

    • Improved handling of cover image URLs based on user settings to ensure proper display without unwanted effects.

Copy link

coderabbitai bot commented Sep 4, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes introduce a new setting, enableCoverImageEdgeCurl, to enhance the Google Books API's cover image handling capabilities. This setting allows users to enable or disable the page curl effect applied to image thumbnails, improving customization options for cover images. Code modifications span across settings, API, and test files, ensuring that the new features are well-documented and functional.

Changes

파일 경로 변경 요약
README.md "Enhancements: Cover Image Display in Search Results" 섹션 추가, 커버 이미지 표시 설정 및 CSS 설명.
src/apis/base_api.ts factoryServiceProvider 함수에서 GoogleBooksApi 인스턴스화 시 enableCoverImageEdgeCurl 매개변수 추가.
src/apis/google_books_api.ts GoogleBooksApi 생성자에 enableCoverImageEdgeCurl 매개변수 추가, URL 처리 개선을 위한 새로운 메서드 추가.
src/apis/google_books_api.test.ts GoogleBooksApi 생성자에 새로운 매개변수 추가 및 "Edge curl" 기능에 대한 테스트 케이스 추가.
src/settings/settings.ts BookSearchPluginSettings 인터페이스에 enableCoverImageEdgeCurl 추가, 기본값을 true로 설정.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Plugin
    participant GoogleBooksApi

    User->>Plugin: 설정 변경 (enableCoverImageEdgeCurl)
    Plugin->>GoogleBooksApi: 인스턴스화 (enableCoverImageEdgeCurl)
    GoogleBooksApi->>GoogleBooksApi: 커버 이미지 URL 생성
    GoogleBooksApi-->>Plugin: URL 반환
    Plugin-->>User: 업데이트된 커버 이미지 표시
Loading

Possibly related PRs

  • feat: add cover image edge curl option #119: This PR directly relates to the main PR as it introduces the "Cover Image Edge Curl" feature, which is also a focus of the main PR. Both PRs enhance the user experience by providing options for managing cover image display settings in the plugin.

Poem

🐰
구름 위를 뛰어넘어,
페이지 컬이 사라져,
커버 이미지는 반짝여,
설정은 내 손안에,
즐거운 책의 세계로,
함께 떠나볼까요! 📚✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f999958 and a6446bc.

Files selected for processing (5)
  • README.md (2 hunks)
  • src/apis/base_api.ts (1 hunks)
  • src/apis/google_books_api.test.ts (2 hunks)
  • src/apis/google_books_api.ts (3 hunks)
  • src/settings/settings.ts (5 hunks)
Additional comments not posted (13)
src/apis/base_api.ts (1)

22-22: LGTM!

GoogleBooksApi 생성자에 settings.enableCoverImageEdgeCurl 매개변수를 추가하여 커버 이미지 가장자리 컬 기능에 대한 제어를 허용하는 변경 사항을 승인합니다. 이 변경으로 인해 GoogleBooksApi의 구성 가능성이 향상되었습니다.

src/apis/google_books_api.ts (4)

11-11: 생성자 서명 변경이 잘 구현되었습니다!

새로운 boolean 매개변수 enableCoverImageEdgeCurl이 추가되었고, 매개변수 이름이 의도를 잘 설명하고 있습니다.


103-107: setCoverImageEdgeCurl 메서드가 잘 구현되었습니다!

URL과 boolean 플래그를 받아서, 플래그가 false인 경우 URL에서 edge curl 매개변수를 제거하는 로직이 잘 구현되었습니다.


68-68: coverUrl 속성 변경이 잘 구현되었습니다!

extractBasicBookInfo 메서드의 coverUrl 속성이 이제 setCoverImageEdgeCurl 메서드를 사용하고 있으며, enableCoverImageEdgeCurl 플래그가 올바르게 전달되고 있습니다.


69-69: coverSmallUrl 속성 변경이 잘 구현되었습니다!

extractBasicBookInfo 메서드의 coverSmallUrl 속성이 이제 setCoverImageEdgeCurl 메서드를 사용하고 있으며, enableCoverImageEdgeCurl 플래그가 올바르게 전달되고 있습니다.

src/apis/google_books_api.test.ts (3)

52-52: LGTM!

코드 변경 사항이 승인되었습니다.


111-114: LGTM!

코드 변경 사항이 승인되었습니다.


116-122: LGTM!

코드 변경 사항이 승인되었습니다.

README.md (1)

130-132: 문서 개선 사항이 잘 반영되었습니다!

새로운 "Cover Image Edge Curl" 섹션은 Google Books API와 관련된 기능을 명확하게 설명하고 있습니다. 이 섹션은 API가 기본적으로 이미지 썸네일에 "페이지 컬" 효과를 적용하며, 사용자에게 이 효과를 비활성화할 수 있는 옵션을 제공한다는 점을 명시하고 있습니다. 이러한 정보의 추가는 책 표지 이미지의 시각적 표현과 사용자가 이를 수정할 수 있는 방법에 대해 사용자에게 알려줌으로써 문서를 개선합니다.

src/settings/settings.ts (4)

35-35: 코드 변경 사항이 승인되었습니다.

BookSearchPluginSettings 인터페이스에 새로운 boolean 속성 enableCoverImageEdgeCurl을 추가하는 것은 올바르고 일관성 있는 변경입니다.


56-56: 코드 변경 사항이 승인되었습니다.

DEFAULT_SETTINGS 상수에 기본값 trueenableCoverImageEdgeCurl 속성을 추가하는 것은 올바르고 일관성 있는 변경입니다.


167-168: 코드 변경 사항이 승인되었습니다.

새로운 변수 coverImageEdgeCurlToggleSetting을 선언하고, serviceProvider에 따라 토글 설정을 표시/숨기기 위한 새로운 함수 hideCoverImageEdgeCurlToggleshowCoverImageEdgeCurlToggle을 추가하는 것은 올바른 변경입니다. toggleServiceProviderExtraSettings 함수도 serviceProvider에 따라 새로운 함수를 호출하도록 업데이트되었습니다. 코드는 기존 패턴과 명명 규칙을 따르고 있습니다.

Also applies to: 185-194, 202-202, 206-206


283-291: 코드 변경 사항이 승인되었습니다.

새로운 설정 coverImageEdgeCurlToggleSetting을 이름, 설명, 토글과 함께 인스턴스화하여 커버 이미지의 가장자리 컬 효과를 활성화/비활성화할 수 있도록 하는 것은 올바른 변경입니다. 토글 값은 플러그인 설정의 enableCoverImageEdgeCurl 속성을 기반으로 설정되며, 토글 값이 변경되면 플러그인 설정의 enableCoverImageEdgeCurl 속성이 업데이트됩니다. 이 설정은 플러그인 설정의 enableCoverImageEdgeCurl 속성과 적절하게 연결되어 있습니다.

@anpigon anpigon merged commit 520dc53 into anpigon:master Oct 9, 2024
@anpigon
Copy link
Owner

anpigon commented Oct 9, 2024

kitschpatrol

Thank you!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants