2020-04-20 14:03:57 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-08-01 02:47:25 -07:00
|
|
|
class StaticController < ApplicationController
|
2021-12-23 12:04:31 -08:00
|
|
|
include ThemeHelper
|
|
|
|
|
2014-08-01 02:47:25 -07:00
|
|
|
def index
|
2014-12-08 05:14:13 -08:00
|
|
|
if user_signed_in?
|
2020-04-20 14:03:57 -07:00
|
|
|
@timeline = current_user.cursored_timeline(last_id: params[:last_id])
|
|
|
|
@timeline_last_id = @timeline.map(&:id).min
|
|
|
|
@more_data_available = !current_user.cursored_timeline(last_id: @timeline_last_id, size: 1).count.zero?
|
|
|
|
|
2014-12-08 05:14:13 -08:00
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
2020-05-08 19:39:09 -07:00
|
|
|
format.js { render layout: false }
|
2014-12-08 05:14:13 -08:00
|
|
|
end
|
2015-08-28 07:36:49 -07:00
|
|
|
else
|
|
|
|
return render 'static/front'
|
2014-12-08 05:14:13 -08:00
|
|
|
end
|
2014-08-01 02:47:25 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def about
|
2022-06-26 08:33:32 -07:00
|
|
|
user_count = User
|
|
|
|
.where.not(confirmed_at: nil)
|
|
|
|
.where("answered_count > 0")
|
|
|
|
.count
|
|
|
|
|
|
|
|
current_ban_count = UserBan
|
|
|
|
.current
|
|
|
|
.joins(:user)
|
|
|
|
.where.not("users.confirmed_at": nil)
|
|
|
|
.where("users.answered_count > 0")
|
|
|
|
.count
|
|
|
|
|
|
|
|
@users = user_count - current_ban_count
|
2021-10-03 11:40:25 -07:00
|
|
|
@questions = Question.count
|
|
|
|
@answers = Answer.count
|
|
|
|
@comments = Comment.count
|
2022-03-26 10:59:11 -07:00
|
|
|
@smiles = Appendable::Reaction.count
|
2014-08-01 02:47:25 -07:00
|
|
|
end
|
2015-01-07 12:30:52 -08:00
|
|
|
|
2021-12-30 08:58:15 -08:00
|
|
|
def linkfilter
|
|
|
|
redirect_to root_path unless params[:url]
|
|
|
|
|
|
|
|
@link = params[:url]
|
|
|
|
end
|
|
|
|
|
2015-01-07 12:30:52 -08:00
|
|
|
def faq
|
|
|
|
|
|
|
|
end
|
2015-01-16 13:36:39 -08:00
|
|
|
|
|
|
|
def privacy_policy
|
|
|
|
|
|
|
|
end
|
2015-01-16 14:16:28 -08:00
|
|
|
|
|
|
|
def terms
|
|
|
|
|
|
|
|
end
|
2021-12-23 12:04:31 -08:00
|
|
|
|
|
|
|
def webapp_manifest
|
|
|
|
render json: {
|
2022-07-17 02:10:29 -07:00
|
|
|
name: APP_CONFIG["site_name"],
|
|
|
|
description: t(".front.subtitle"),
|
|
|
|
start_url: root_url(source: "pwa"),
|
|
|
|
scope: root_url,
|
|
|
|
display: "standalone",
|
|
|
|
categories: %w[social],
|
|
|
|
lang: I18n.locale,
|
|
|
|
shortcuts: [
|
|
|
|
webapp_shortcut(inbox_url, t("views.navigation.inbox"), "inbox")
|
2021-12-23 12:04:31 -08:00
|
|
|
],
|
2022-07-17 02:10:29 -07:00
|
|
|
icons: webapp_icons,
|
|
|
|
theme_color: theme_color,
|
2021-12-23 12:04:31 -08:00
|
|
|
background_color: mobile_theme_color,
|
|
|
|
}
|
|
|
|
end
|
2022-07-17 02:10:29 -07:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def webapp_shortcut(url, name, icon_name)
|
|
|
|
{
|
|
|
|
name: name,
|
|
|
|
url: url,
|
|
|
|
icons: [
|
|
|
|
{
|
|
|
|
src: "/icons/shortcuts/#{icon_name}.svg",
|
|
|
|
sizes: "96x96"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def webapp_icons
|
|
|
|
%i[1024 512 384 192 128 96 72 48].map do |size|
|
|
|
|
[
|
|
|
|
{ src: "/icons/maskable_icon_x#{size}.webp", size: "#{size}x#{size}", type: "image/webp" },
|
|
|
|
{ src: "/icons/maskable_icon_x#{size}.png", size: "#{size}x#{size}", type: "image/png" }
|
|
|
|
]
|
|
|
|
end.flatten
|
|
|
|
end
|
2014-08-01 02:47:25 -07:00
|
|
|
end
|