main
rb 23 lines 924 Bytes
Raw
1 # frozen_string_literal: true
2
3 # XML sitemap for search engines. Public — fetched anonymously — and lists the
4 # static marketing/legal pages plus every public repository and the profiles
5 # that own them. Private repos (and the users with only private repos) are
6 # excluded so nothing behind auth leaks into the index.
7 class SitemapsController < ApplicationController
8 # Cap the URL count well under the 50k / 50MB sitemap limit; newest content
9 # first so the most relevant pages are always present.
10 MAX_REPOSITORIES = 10_000
11
12 def index
13 @repositories = Repository.where(is_private: false)
14 .includes(:user)
15 .order(updated_at: :desc)
16 .limit(MAX_REPOSITORIES)
17 @profiles = @repositories.filter_map(&:user).uniq
18 @changelog_entries = Changelog.all
19
20 expires_in 6.hours, public: true
21 respond_to(&:xml)
22 end
23 end