-
-
Notifications
You must be signed in to change notification settings - Fork 120
feat: Add repository URLs to sitemap (Closes #1755) #1761
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
base: main
Are you sure you want to change the base?
feat: Add repository URLs to sitemap (Closes #1755) #1761
Conversation
Summary by CodeRabbit
WalkthroughA new Changes
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
Documentation and Community
|
|
There was a problem hiding this 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)
backend/apps/sitemap/views/repository.py (1)
20-27
: Fix formatting issues and verify URL behavior.The code has formatting issues that need to be addressed:
Apply this diff to fix the formatting:
- ).order_by("-updated_at","-created_at") - + ).order_by("-updated_at","-created_at") + def lastmod(self, obj): - """Return the last modification date.""" - return obj.updated_at + """Return the last modification date.""" + return obj.updated_at def location(self, obj): - """Return the absolute (GitHub) URL.""" - return obj.url + """Return the absolute (GitHub) URL.""" + return obj.urlAdditionally, please verify that returning the GitHub URL (
obj.url
) is the intended behavior. Typically, sitemaps point to internal application pages rather than external URLs. Consider whether this should point to an internal repository detail page instead.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
backend/apps/sitemap/views/__init__.py
(1 hunks)backend/apps/sitemap/views/repository.py
(1 hunks)backend/apps/sitemap/views/static.py
(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
backend/apps/sitemap/views/static.py (2)
backend/apps/github/graphql/queries/repository.py (1)
repository
(14-35)backend/apps/github/models/repository.py (1)
Repository
(25-349)
🪛 Ruff (0.12.2)
backend/apps/sitemap/views/repository.py
20-20: Blank line contains whitespace
Remove whitespace from blank line
(W293)
27-27: No newline at end of file
Add trailing newline
(W292)
🔇 Additional comments (6)
backend/apps/sitemap/views/__init__.py (1)
12-12
: LGTM!The import follows the existing pattern and correctly integrates the new
RepositorySitemap
class.backend/apps/sitemap/views/static.py (2)
8-8
: LGTM!The import correctly adds the Repository model following the established pattern.
38-38
: LGTM!The addition of the
/repositories
path mapping enables proper last modification tracking for the repositories route, following the established pattern.backend/apps/sitemap/views/repository.py (3)
1-10
: LGTM!The class structure and attributes are correctly implemented, following Django sitemap conventions.
12-19
: Well-designed filtering logic.The repository filtering criteria are appropriate for a sitemap - excluding archived, empty, and forked repositories while focusing on active OWASP repositories. The ordering by recent updates prioritizes the most relevant content.
21-23
: LGTM!Using
updated_at
for the last modification timestamp is appropriate for sitemap generation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @ShubhamSingh-dev
Please note we have some rules here:
- you don't work on issues until you get assigned
- you must follow our contribution guidelines -- running checks/tests before sending your code for review
Please mark your PR as ready for review when you fix it.
- we require tests for new code (see the guidelines)
Hi @arkid15r, Regarding the CodeRabbit comment on the location method in RepositorySitemap (specifically about obj.url pointing to an external GitHub page): Could you please clarify the intended behavior for repository sitemap entries? Should they point to: a) The external GitHub repository page (as currently implemented via obj.url)? Your guidance on this would be greatly appreciated to ensure the sitemap aligns with the project's long-term vision. |
@ShubhamSingh-dev it should point to the internal OWASP Nest repository page (e.g. https://nest.owasp.org/organizations/OWASP/repositories/nest) |
Resolves #1755
This PR addresses Issue #1755: "Improve sitemap w/ Repository related URLs."
It enhances the sitemap by programmatically including URLs for public OWASP repositories. This was achieved by:
RepositorySitemap
class inbackend/apps/sitemap/views/repository.py
responsible for querying and formatting these repository links.RepositorySitemap
into the main sitemap configuration inbackend/apps/sitemap/views/__init__.py
.path_to_model
mapping inbackend/apps/sitemap/views/static.py
to ensure thelastmod
for the/repositories
static page (if it exists) accurately reflects the latest repository updates.This implementation ensures better search engine discoverability for the OWASP Nest project's associated repositories.