2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-02-16 19:26:25 -06:00
|
|
|
class SiteController < ApplicationController
|
2016-02-13 12:29:53 -06:00
|
|
|
layout false
|
2017-08-30 23:06:56 -05:00
|
|
|
skip_before_action :preload_json, :check_xhr
|
2023-01-09 06:20:10 -06:00
|
|
|
skip_before_action :redirect_to_login_if_required, only: %w[basic_info statistics]
|
2015-05-20 02:12:16 -05:00
|
|
|
|
2015-03-04 22:49:03 -06:00
|
|
|
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
|
2014-02-16 19:26:25 -06:00
|
|
|
end
|
2016-08-12 02:10:08 -05:00
|
|
|
|
|
|
|
def basic_info
|
|
|
|
results = {
|
2018-11-14 01:03:02 -06:00
|
|
|
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),
|
2018-12-04 03:48:16 -06:00
|
|
|
favicon_url: UrlHelper.absolute(SiteSetting.site_favicon_url),
|
2016-08-12 02:10:08 -05:00
|
|
|
title: SiteSetting.title,
|
2018-10-08 04:52:57 -05:00
|
|
|
description: SiteSetting.site_description,
|
2023-01-09 06:20:10 -06:00
|
|
|
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,
|
2016-08-12 02:10:08 -05:00
|
|
|
}
|
2018-11-14 01:03:02 -06:00
|
|
|
|
|
|
|
if mobile_logo_url = SiteSetting.site_mobile_logo_url.presence
|
|
|
|
results[:mobile_logo_url] = UrlHelper.absolute(mobile_logo_url)
|
|
|
|
end
|
2016-08-12 02:10:08 -05:00
|
|
|
|
2024-02-23 00:12:28 -06:00
|
|
|
results[:discourse_discover_enrolled] = true if SiteSetting.include_in_discourse_discover?
|
|
|
|
|
2017-03-27 07:47:07 -05:00
|
|
|
DiscourseHub.stats_fetched_at = Time.zone.now if request.user_agent == "Discourse Hub"
|
2016-08-12 02:10:08 -05:00
|
|
|
|
|
|
|
# this info is always available cause it can be scraped from a 404 page
|
|
|
|
render json: results
|
|
|
|
end
|
2017-03-10 07:16:00 -06:00
|
|
|
|
|
|
|
def statistics
|
2023-01-09 06:20:10 -06:00
|
|
|
return redirect_to path("/") unless SiteSetting.share_anonymized_statistics?
|
2017-03-10 07:16:00 -06:00
|
|
|
render json: About.fetch_cached_stats
|
|
|
|
end
|
2014-02-21 11:31:54 -06:00
|
|
|
end
|