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

Add screenshots from Git repository #7459

Closed
aparcar opened this issue Apr 2, 2022 · 6 comments · Fixed by #8610
Closed

Add screenshots from Git repository #7459

aparcar opened this issue Apr 2, 2022 · 6 comments · Fixed by #8610
Assignees
Labels
backlog This is not on the Weblate roadmap for now. Can be prioritized by sponsorship. enhancement Adding or requesting a new feature.
Milestone

Comments

@aparcar
Copy link

aparcar commented Apr 2, 2022

Describe the problem

Managing the screenshots is detected from the people changing the code, meaning screenshots likely get out of sync. It would be nice if the people creating the code could also provide the screenshots and add them to a Git repository.

Describe the solution you'd like

It would be nice to add and update screenshots via a Git repository. A component containing images called screenshot[-<foobar>].png should be automatically be added to that component.

Describe alternatives you've considered

Do it manually.

Screenshots

No response

Additional context

No response

@github-actions

This comment was marked as off-topic.

@github-actions github-actions bot added the wontfix Nobody will work on this. label Apr 13, 2022
@nijel nijel added enhancement Adding or requesting a new feature. backlog This is not on the Weblate roadmap for now. Can be prioritized by sponsorship. and removed wontfix Nobody will work on this. labels Apr 13, 2022
@github-actions
Copy link

This issue has been added to the backlog. It is not scheduled on the Weblate roadmap, but it eventually might be implemented.

In case you need this feature soon, please consider helping or push it by funding the development.

@nijel
Copy link
Member

nijel commented Sep 19, 2022

Let's split this to two parts:

  • Allow updating existing screenshots from the repository. Once the file in the repository is changed, the screenshot content would be updated. For Weblate it would be for example docs/screenshots/file-download.png to automatically get https://github.com/WeblateOrg/weblate/blob/main/docs/screenshots/file-download.png
  • Allow discovery of new screenshots. Component configuration would get a Screenshot file mask and all files which do not have matching Screenshot would be imported. For Weblate, the mask would be docs/screenshots/*.png.

Implementation wise, this needs:

  • Add Repository filename field to the Screenshot model
  • Scan these files on repository update and update existing screenshots
  • Add Screenshot file mask field to the Component model
  • Scan files matching Screenshot file mask on repository update and create new screenshots

@ParthS007
Copy link
Member

@nijel I started working on it. What I understand and added so far

  1. The Screenshot having a field repository_filename. The scan will get triggered after the result is there https://github.com/WeblateOrg/weblate/blob/main/weblate/trans/models/component.py#L1347
repository_filename = models.CharField(
        verbose_name=_("Repository path to screenshot"),
        help_text=_("Scan for screenshot file change on repository update."),
        max_length=200,
    )

Some questions:

  • Is the above location correct?
  • What would be the parameters to check for a change in file, size would be okay or some other addition as well?
  • We have to use the repo_web field in Component to get the link of file?
  1. After having screenshot_filemask , whenever there is update on repository, it will scan the path files with present screenshots and add the ones that are not present.
screenshot_filemask = models.CharField(
        verbose_name=gettext_lazy("Screenshot file mask"),
        max_length=FILENAME_LENGTH,
        validators=[validate_filemask, validate_filename],
        help_text=gettext_lazy(
            "Path of screenshots relative to repository root,"
            "for example: docs/screenshots/*.png."
        ),
    )

question:

@nijel
Copy link
Member

nijel commented Oct 19, 2022

  • Is the above location correct?

Yes.

* What would be the parameters to check for a change in file,  `size` would be okay or some other addition as well?

I'd probably rather look at the content of the file. The content of the file should be also validated by validate_bitmap prior using.

In case we would want to optimize this, we get changed files from the repository using Repository.list_changed_files. This will need an additional layer to make this work for all supported VCSes (similar to Repository.list_upstream_changed_files).

* We have to use the `repo_web` field in `Component` to get the link of file?

I'd avoid doing external requests for screenshots, so instead the Screenshot.image object should be updated to match the file in the repository.

* The trigger will happen here https://github.com/WeblateOrg/weblate/blob/main/weblate/trans/models/component.py#L1347?

I'd rather do it indirectly - hook on vcs_post_update signal. This way the code can fully live in the screenshots module. Also, the update should be executed in a background task to avoid delaying component update.

@github-actions
Copy link

Thank you for your report; the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog This is not on the Weblate roadmap for now. Can be prioritized by sponsorship. enhancement Adding or requesting a new feature.
Projects
None yet
3 participants