mirror of
https://github.com/discourse/discourse.git
synced 2024-12-28 13:13:51 +08:00
9dc6325821
We will be collecting the logo URL and the site's default locale values along with existing basic details to display the site on the Discourse Discover listing page. It will be included only if the site is opted-in by enabling the "`include_in_discourse_discover`" site setting. Also, we no longer going to use `about.json` and `site/statistics.json` endpoints retrieve these data. We will be using only the `site/basic-info.json` endpoint.
62 lines
1.8 KiB
Ruby
62 lines
1.8 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class SiteController < ApplicationController
|
|
layout false
|
|
skip_before_action :preload_json, :check_xhr
|
|
skip_before_action :redirect_to_login_if_required, only: %w[basic_info statistics]
|
|
|
|
def site
|
|
render json: Site.json_for(guardian)
|
|
end
|
|
|
|
def settings
|
|
render json: SiteSetting.client_settings_json
|
|
end
|
|
|
|
def custom_html
|
|
render json: custom_html_json
|
|
end
|
|
|
|
def banner
|
|
render json: banner_json
|
|
end
|
|
|
|
def emoji
|
|
render json: custom_emoji
|
|
end
|
|
|
|
def basic_info
|
|
results = {
|
|
logo_url: UrlHelper.absolute(SiteSetting.site_logo_url),
|
|
logo_small_url: UrlHelper.absolute(SiteSetting.site_logo_small_url),
|
|
apple_touch_icon_url: UrlHelper.absolute(SiteSetting.site_apple_touch_icon_url),
|
|
favicon_url: UrlHelper.absolute(SiteSetting.site_favicon_url),
|
|
title: SiteSetting.title,
|
|
description: SiteSetting.site_description,
|
|
header_primary_color: ColorScheme.hex_for_name("header_primary") || "333333",
|
|
header_background_color: ColorScheme.hex_for_name("header_background") || "ffffff",
|
|
login_required: SiteSetting.login_required,
|
|
}
|
|
|
|
if mobile_logo_url = SiteSetting.site_mobile_logo_url.presence
|
|
results[:mobile_logo_url] = UrlHelper.absolute(mobile_logo_url)
|
|
end
|
|
|
|
if guardian.is_discourse_hub_request?
|
|
DiscourseHub.stats_fetched_at = Time.zone.now
|
|
discover_data = About.discourse_discover
|
|
discover_data.each_key do |key|
|
|
results["discourse_discover_#{key}".to_sym] = discover_data[key]
|
|
end
|
|
end
|
|
|
|
# this info is always available cause it can be scraped from a 404 page
|
|
render json: results
|
|
end
|
|
|
|
def statistics
|
|
return redirect_to path("/") unless SiteSetting.share_anonymized_statistics?
|
|
render json: About.fetch_cached_stats
|
|
end
|
|
end
|