Skip to content

Conversation

@hect0x7
Copy link
Owner

@hect0x7 hect0x7 commented Jul 17, 2025

Summary by CodeRabbit

  • New Features

    • Added support for encrypting generated PDF files with a password in the PDF creation plugin.
    • Album descriptions are now extracted and displayed where supported.
  • Documentation

    • Updated option file documentation to include the new PDF encryption configuration.
  • Other

    • Updated version to 2.6.4.

@coderabbitai
Copy link

coderabbitai bot commented Jul 17, 2025

Walkthrough

This update introduces optional PDF encryption support to the img2pdf plugin, allowing users to specify a password for generated PDFs. The JmAlbumDetail entity now includes a description field, and the toolkit is updated to extract album descriptions from HTML. Documentation and versioning are updated accordingly.

Changes

File(s) Summary
assets/docs/sources/option_file_syntax.md Added documentation for optional encrypt configuration in the img2pdf plugin.
src/jmcomic/init.py Updated version string from '2.6.3' to '2.6.4'.
src/jmcomic/jm_entity.py Added optional description parameter to JmAlbumDetail and assigned it as an instance attribute.
src/jmcomic/jm_plugin.py Added optional encrypt parameter to img2pdf plugin; implemented PDF encryption logic.
src/jmcomic/jm_toolkit.py Added regex for album description extraction; updated adapter to map descriptions to entities.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Img2pdfPlugin
    participant PDFWriter
    participant PikePDF

    User->>Img2pdfPlugin: invoke(photo, album, ..., encrypt)
    Img2pdfPlugin->>PDFWriter: write_img_2_pdf(pdf_filepath, album, photo, encrypt)
    PDFWriter->>PDFWriter: img2pdf.convert(images)
    alt encrypt is provided
        PDFWriter->>PikePDF: encrypt_pdf(pdf_filepath, encrypt)
        PikePDF->>PDFWriter: Save encrypted PDF
    end
    PDFWriter-->>Img2pdfPlugin: return
    Img2pdfPlugin-->>User: return
Loading

Possibly related PRs

  • Dev #412: Also updates the version string in src/jmcomic/__init__.py, representing an independent version bump.
  • Dev #449: Updates the version string in src/jmcomic/__init__.py, similar to this PR but for a different version.

Poem

A hop, a skip, encryption’s here—
Now your PDFs are safe, no fear!
Album descriptions join the fun,
Version bumped, the work is done.
With regex paws and password keys,
This bunny codes with nimble ease!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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

🧹 Nitpick comments (1)
src/jmcomic/jm_plugin.py (1)

804-814: PDF encryption implementation is robust.

The encrypt_pdf method includes proper error handling for missing dependencies and uses the appropriate pikepdf library for PDF encryption. The password extraction from the encrypt dictionary is handled safely.

Consider whether logging the password might be a security concern:

 password = str(encrypt.get('password', ''))
+# Note: Password is logged for debugging purposes
 with pikepdf.open(pdf_filepath, allow_overwriting_input=True) as pdf:
     pdf.save(pdf_filepath, encryption=pikepdf.Encryption(user=password, owner=password))

If this is intentional for debugging, consider adding a comment. Otherwise, you might want to avoid logging sensitive information.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c4faf3a and 039b9cc.

📒 Files selected for processing (5)
  • assets/docs/sources/option_file_syntax.md (1 hunks)
  • src/jmcomic/__init__.py (1 hunks)
  • src/jmcomic/jm_entity.py (1 hunks)
  • src/jmcomic/jm_plugin.py (3 hunks)
  • src/jmcomic/jm_toolkit.py (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/jmcomic/jm_plugin.py (1)
src/jmcomic/jm_entity.py (2)
  • JmAlbumDetail (454-568)
  • JmPhotoDetail (292-451)
🪛 Ruff (0.12.2)
src/jmcomic/jm_plugin.py

777-777: JmAlbumDetail may be undefined, or defined from star imports

(F405)


777-777: JmPhotoDetail may be undefined, or defined from star imports

(F405)

🔇 Additional comments (10)
src/jmcomic/__init__.py (1)

5-5: Version bump looks correct.

The version increment to 2.6.4 appropriately reflects the new features added in this PR (description field and PDF encryption support).

assets/docs/sources/option_file_syntax.md (1)

282-283: Documentation update looks good.

The addition of the encrypt parameter documentation with a clear example helps users understand how to configure PDF password protection for the img2pdf plugin.

src/jmcomic/jm_toolkit.py (2)

29-29: Regex pattern for description extraction looks correct.

The pattern r'叙述:([\s\S]*?)</h2>' appropriately captures album descriptions from HTML content using a non-greedy match to extract text between "叙述:" and the closing </h2> tag.


655-655: Field adapter extension is properly implemented.

Adding 'description' to the JmAlbumDetail field adapter correctly enables extraction and mapping of album descriptions from API data into the album entity.

src/jmcomic/jm_entity.py (2)

472-472: Constructor parameter addition is well-designed.

The optional description parameter with a default empty string maintains backward compatibility while enabling the new functionality.


478-478: Description processing follows established patterns.

The description field is processed consistently with other string fields using str(description).strip(), maintaining code consistency.

src/jmcomic/jm_plugin.py (4)

752-752: Encrypt parameter addition maintains backward compatibility.

The optional encrypt parameter is well-designed, allowing users to opt into PDF encryption without breaking existing functionality.


770-770: Parameter passing is correctly implemented.

The encrypt parameter is properly passed through to the write_img_2_pdf method, maintaining the chain of data flow.


799-800: Conditional encryption is properly implemented.

The encryption is appropriately applied only when the encrypt parameter is provided, with proper control flow.


777-777: Verified availability of JmAlbumDetail and JmPhotoDetail via star-import chain

Both types are defined in src/jmcomic/jm_entity.py and are pulled into jm_plugin.py through the following chain of from *.import * statements:

  • jm_plugin.py: from .jm_option import *
  • jm_option.py: from .jm_client_impl import *
  • jm_client_impl.py → jm_client_interface.py → jm_toolkit.py → jm_exception.py → jm_entity.py

Since jm_entity.py declares class JmAlbumDetail and class JmPhotoDetail, they’re available at runtime and for type checkers. No changes required.

@hect0x7 hect0x7 merged commit 2cb5455 into master Jul 17, 2025
@hect0x7 hect0x7 deleted the dev branch July 17, 2025 17:02
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