Skip to content

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ShubhamSingh-dev
Copy link

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:

  • Introducing a new RepositorySitemap class in backend/apps/sitemap/views/repository.py responsible for querying and formatting these repository links.
  • Integrating RepositorySitemap into the main sitemap configuration in backend/apps/sitemap/views/__init__.py.
  • (If applicable) Updating the path_to_model mapping in backend/apps/sitemap/views/static.py to ensure the lastmod 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.

Copy link
Contributor

coderabbitai bot commented Jul 20, 2025

Summary by CodeRabbit

  • New Features

    • Added a sitemap for repositories, allowing users and search engines to discover repository URLs more easily.
  • Improvements

    • The sitemap now includes last modification dates for the repositories section, ensuring more accurate update information for search engines.

Walkthrough

A new RepositorySitemap class was introduced to generate sitemaps for repository URLs, filtering for relevant repositories. The sitemap views' __init__.py was updated to import this new class. Additionally, the static sitemap logic was adjusted to recognize /repositories as a route associated with the Repository model for last modification tracking.

Changes

Files/Groups Change Summary
backend/apps/sitemap/views/repository.py Added RepositorySitemap class with methods for filtering, last modification, and URL generation.
backend/apps/sitemap/views/__init__.py Imported RepositorySitemap into the sitemap views package.
backend/apps/sitemap/views/static.py Updated StaticSitemap.lastmod to map /repositories to the Repository model for lastmod lookup.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 auto-generate unit tests to generate unit tests for 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.

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

Copy link
Contributor

@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)
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.url

Additionally, 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

📥 Commits

Reviewing files that changed from the base of the PR and between cca15f5 and 5fcd437.

📒 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.

Copy link
Collaborator

@arkid15r arkid15r left a 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)

@arkid15r arkid15r marked this pull request as draft July 20, 2025 18:48
@ShubhamSingh-dev
Copy link
Author

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)?
b) An internal repository detail page within the Nest application (e.g., /repositories/{nest_key})?

Your guidance on this would be greatly appreciated to ensure the sitemap aligns with the project's long-term vision.
Thank you!

@arkid15r
Copy link
Collaborator

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)? b) An internal repository detail page within the Nest application (e.g., /repositories/{nest_key})?

Your guidance on this would be greatly appreciated to ensure the sitemap aligns with the project's long-term vision. Thank you!

@ShubhamSingh-dev it should point to the internal OWASP Nest repository page (e.g. https://nest.owasp.org/organizations/OWASP/repositories/nest)

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

Successfully merging this pull request may close these issues.

Improve sitemap w/ Repository related URLs
2 participants