2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-02-17 09:26:25 +08:00
|
|
|
class SiteController < ApplicationController
|
2016-02-14 02:29:53 +08:00
|
|
|
layout false
|
2017-08-31 12:06:56 +08:00
|
|
|
skip_before_action :preload_json, :check_xhr
|
2024-06-25 19:32:18 +08:00
|
|
|
skip_before_action :redirect_to_login_if_required,
|
|
|
|
:redirect_to_profile_if_required,
|
|
|
|
only: %w[basic_info statistics]
|
2015-05-20 15:12:16 +08:00
|
|
|
|
2015-03-05 12:49:03 +08: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-17 09:26:25 +08:00
|
|
|
end
|
2016-08-12 15:10:08 +08:00
|
|
|
|
|
|
|
def basic_info
|
|
|
|
results = {
|
2018-11-14 15:03:02 +08: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 17:48:16 +08:00
|
|
|
favicon_url: UrlHelper.absolute(SiteSetting.site_favicon_url),
|
2016-08-12 15:10:08 +08:00
|
|
|
title: SiteSetting.title,
|
2018-10-08 17:52:57 +08:00
|
|
|
description: SiteSetting.site_description,
|
|
|
|
header_primary_color: ColorScheme.hex_for_name("header_primary") || "333333",
|
2021-08-18 02:05:51 +08:00
|
|
|
header_background_color: ColorScheme.hex_for_name("header_background") || "ffffff",
|
|
|
|
login_required: SiteSetting.login_required,
|
2024-04-23 21:52:01 +08:00
|
|
|
locale: SiteSetting.default_locale,
|
|
|
|
include_in_discourse_discover: SiteSetting.include_in_discourse_discover,
|
2016-08-12 15:10:08 +08:00
|
|
|
}
|
2018-11-14 15:03:02 +08:00
|
|
|
|
|
|
|
if mobile_logo_url = SiteSetting.site_mobile_logo_url.presence
|
|
|
|
results[:mobile_logo_url] = UrlHelper.absolute(mobile_logo_url)
|
|
|
|
end
|
2016-08-12 15:10:08 +08:00
|
|
|
|
|
|
|
# this info is always available cause it can be scraped from a 404 page
|
|
|
|
render json: results
|
|
|
|
end
|
2017-03-10 21:16:00 +08:00
|
|
|
|
|
|
|
def statistics
|
|
|
|
return redirect_to path("/") unless SiteSetting.share_anonymized_statistics?
|
|
|
|
render json: About.fetch_cached_stats
|
|
|
|
end
|
2014-02-22 01:31:54 +08:00
|
|
|
end
|