-
-
Notifications
You must be signed in to change notification settings - Fork 958
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
Default (infer) "Repository browser" link template from "Source code repository" #7865
Comments
Currently, these are configured separately, so it's up to the admin to configure it or not. In case it will be automatically generated from VCS location, it should honor the |
@nijel Can you please add some implementation details here. Thanks 👍 |
The following code needs to be expanded to fall back to repo URL-based template if repoweb is not set: weblate/weblate/trans/models/component.py Line 1155 in 5bfcb77
|
I started working it and I have following findings:
|
The integration is selected by the template = getattr(self, f"get_{self.vcs}_repoweb_template", self.get_git_repoweb_template)()
def get_git_repoweb_template(self):
# Do a repo URL based detection here
if self.repo looks like GitHub:
return self.get_github_repoweb_template()
...
return None
def get_github_repoweb_template(self):
# Extract domain, owner and slug from the repo URL
return f"https://{domain}/{owner}/{slug}/blob/{{branch}}/{{filename}}#L{{line}}" For parsing the URLs and detecting the services, you might utilize URL detection in the hooks (though that one is for the opposite direction): weblate/weblate/trans/views/hooks.py Lines 42 to 80 in b56a360
|
I added the url detection for services, I was not sure on how the URL will look like for services other than github, so kept them as to do for now. Please let me know if it is the right direction and how can I test the functionality. I went through the tests, i am assuming now I have to test something like this? https://github.com/WeblateOrg/weblate/blob/main/weblate/trans/tests/test_templatetags.py#L129-L149 |
Thank you for your report; the issue you have reported has just been fixed.
|
Describe the problem
Unless you explicitly specify "Repository browser" link template, repository browser links will never be generated (they'll remain as text). But we can infer them (at least for popular services like GitHub, GitLab, Bitbucket).
Describe the solution you'd like
Either fill the "Repository browser" field automatically, or default here:
weblate/weblate/trans/models/component.py
Line 1155 in 5bfcb77
Describe alternatives you've considered
No response
Screenshots
Additional context
Inspired by this comment #7738 (comment)
The text was updated successfully, but these errors were encountered: