Merge branch 'master' into glitch-soc/merge-upstream

signup-info-prompt
Thibaut Girka 2018-07-17 22:05:25 +02:00
commit 7dbed4dab9
20 changed files with 360 additions and 36 deletions

View File

@ -0,0 +1,43 @@
# frozen_string_literal: true
require 'sidekiq/api'
module Admin
class DashboardController < BaseController
def index
@users_count = User.count
@registrations_week = Redis.current.get("activity:accounts:local:#{current_week}") || 0
@logins_week = Redis.current.pfcount("activity:logins:#{current_week}")
@interactions_week = Redis.current.get("activity:interactions:#{current_week}") || 0
@relay_enabled = Relay.enabled.exists?
@single_user_mode = Rails.configuration.x.single_user_mode
@registrations_enabled = Setting.open_registrations
@deletions_enabled = Setting.open_deletion
@invites_enabled = Setting.min_invite_role == 'user'
@search_enabled = Chewy.enabled?
@version = Mastodon::Version.to_s
@database_version = ActiveRecord::Base.connection.execute('SELECT VERSION()').first['version'].match(/\A(?:PostgreSQL |)([^\s]+).*\z/)[1]
@redis_version = redis_info['redis_version']
@reports_count = Report.unresolved.count
@queue_backlog = Sidekiq::Stats.new.enqueued
@recent_users = User.confirmed.recent.includes(:account).limit(4)
@database_size = ActiveRecord::Base.connection.execute('SELECT pg_database_size(current_database())').first['pg_database_size']
@redis_size = redis_info['used_memory']
@ldap_enabled = ENV['LDAP_ENABLED'] == 'true'
@cas_enabled = ENV['CAS_ENABLED'] == 'true'
@saml_enabled = ENV['SAML_ENABLED'] == 'true'
@pam_enabled = ENV['PAM_ENABLED'] == 'true'
@hidden_service = ENV['ALLOW_ACCESS_TO_HIDDEN_SERVICE'] == 'true'
@trending_hashtags = TrendingTags.get(7)
end
private
def current_week
@current_week ||= Time.now.utc.to_date.cweek
end
def redis_info
@redis_info ||= Redis.current.info
end
end
end

View File

@ -170,7 +170,7 @@
"navigation_bar.domain_blocks": "Ukryte domeny",
"navigation_bar.edit_profile": "Edytuj profil",
"navigation_bar.favourites": "Ulubione",
"navigation_bar.filters": "Muted words",
"navigation_bar.filters": "Wyciszone słowa",
"navigation_bar.follow_requests": "Prośby o śledzenie",
"navigation_bar.info": "Szczegółowe informacje",
"navigation_bar.keyboard_shortcuts": "Skróty klawiszowe",

View File

@ -21,5 +21,6 @@
@import 'mastodon/about';
@import 'mastodon/tables';
@import 'mastodon/admin';
@import 'mastodon/dashboard';
@import 'mastodon/rtl';
@import 'mastodon/accessibility';

View File

@ -923,7 +923,7 @@ $small-breakpoint: 960px;
}
@media screen and (max-width: $column-breakpoint) {
height: 90vh;
display: none;
}
}

View File

@ -0,0 +1,69 @@
.dashboard__counters {
display: flex;
flex-wrap: wrap;
margin: 0 -5px;
margin-bottom: 20px;
& > div {
box-sizing: border-box;
flex: 0 0 33.333%;
padding: 0 5px;
margin-bottom: 10px;
& > div,
& > a {
padding: 20px;
background: lighten($ui-base-color, 4%);
border-radius: 4px;
}
& > a {
text-decoration: none;
color: inherit;
display: block;
&:hover,
&:focus,
&:active {
background: lighten($ui-base-color, 8%);
}
}
}
&__num {
text-align: center;
font-weight: 500;
font-size: 24px;
color: $primary-text-color;
font-family: 'mastodon-font-display', sans-serif;
margin-bottom: 20px;
}
&__label {
font-size: 14px;
color: $darker-text-color;
text-align: center;
font-weight: 500;
}
}
.dashboard__widgets {
display: flex;
flex-wrap: wrap;
margin: 0 -5px;
& > div {
flex: 0 0 33.333%;
margin-bottom: 20px;
& > div {
padding: 0 5px;
}
}
a:not(.name-tag) {
color: $ui-secondary-color;
font-weight: 500;
text-decoration: none;
}
}

View File

@ -2,6 +2,10 @@
clear: both;
box-shadow: 0 0 15px rgba($base-shadow-color, 0.2);
div[data-component] {
width: 100%;
}
.entry {
background: $simple-background-color;

View File

@ -2,7 +2,7 @@
class Sanitize
module Config
HTTP_PROTOCOLS ||= ['http', 'https', :relative].freeze
HTTP_PROTOCOLS ||= ['http', 'https', 'dat', 'dweb', 'ipfs', 'ipns', 'ssb', 'gopher', :relative].freeze
CLASS_WHITELIST_TRANSFORMER = lambda do |env|
node = env[:node]

View File

@ -1,7 +1,10 @@
# frozen_string_literal: true
class TrendingTags
KEY = 'trending_tags'
EXPIRE_HISTORY_AFTER = 7.days.seconds
EXPIRE_TRENDS_AFTER = 1.day.seconds
THRESHOLD = 5
class << self
def record_use!(tag, account, at_time = Time.now.utc)
@ -9,6 +12,14 @@ class TrendingTags
increment_historical_use!(tag.id, at_time)
increment_unique_use!(tag.id, account.id, at_time)
increment_vote!(tag.id, at_time)
end
def get(limit)
key = "#{KEY}:#{Time.now.utc.beginning_of_day.to_i}"
tag_ids = redis.zrevrange(key, 0, limit - 1).map(&:to_i)
tags = Tag.where(id: tag_ids).to_a.map { |tag| [tag.id, tag] }.to_h
tag_ids.map { |tag_id| tags[tag_id] }.compact
end
private
@ -25,6 +36,22 @@ class TrendingTags
redis.expire(key, EXPIRE_HISTORY_AFTER)
end
def increment_vote!(tag_id, at_time)
key = "#{KEY}:#{at_time.beginning_of_day.to_i}"
expected = redis.pfcount("activity:tags:#{tag_id}:#{(at_time - 1.day).beginning_of_day.to_i}:accounts").to_f
expected = 1.0 if expected.zero?
observed = redis.pfcount("activity:tags:#{tag_id}:#{at_time.beginning_of_day.to_i}:accounts").to_f
if expected > observed || observed < THRESHOLD
redis.zrem(key, tag_id.to_s)
else
score = ((observed - expected)**2) / expected
redis.zadd(key, score, tag_id.to_s)
end
redis.expire(key, EXPIRE_TRENDS_AFTER)
end
def disallowed_hashtags
return @disallowed_hashtags if defined?(@disallowed_hashtags)

View File

@ -37,6 +37,7 @@ class FavouriteService < BaseService
end
def bump_potential_friendship(account, status)
ActivityTracker.increment('activity:interactions')
return if account.following?(status.account_id)
PotentialFriendshipTracker.record(account.id, status.account_id, :favourite)
end

View File

@ -86,7 +86,9 @@ class PostStatusService < BaseService
end
def bump_potential_friendship(account, status)
return if !status.reply? || account.following?(status.in_reply_to_account_id)
return if !status.reply? || account.id == status.in_reply_to_account_id
ActivityTracker.increment('activity:interactions')
return if account.following?(status.in_reply_to_account_id)
PotentialFriendshipTracker.record(account.id, status.in_reply_to_account_id, :reply)
end
end

View File

@ -47,6 +47,7 @@ class ReblogService < BaseService
end
def bump_potential_friendship(account, reblog)
ActivityTracker.increment('activity:interactions')
return if account.following?(reblog.reblog.account_id)
PotentialFriendshipTracker.record(account.id, reblog.reblog.account_id, :reblog)
end

View File

@ -0,0 +1,149 @@
- content_for :page_title do
= t('admin.dashboard.title')
.dashboard__counters
%div
= link_to admin_accounts_url(local: 1, recent: 1) do
.dashboard__counters__num= number_with_delimiter @users_count
.dashboard__counters__label= t 'admin.dashboard.total_users'
%div
%div
.dashboard__counters__num= number_with_delimiter @registrations_week
.dashboard__counters__label= t 'admin.dashboard.week_users_new'
%div
%div
.dashboard__counters__num= number_with_delimiter @logins_week
.dashboard__counters__label= t 'admin.dashboard.week_users_active'
%div
%div
.dashboard__counters__num= number_with_delimiter @interactions_week
.dashboard__counters__label= t 'admin.dashboard.week_interactions'
%div
= link_to admin_reports_url do
.dashboard__counters__num= number_with_delimiter @reports_count
.dashboard__counters__label= t 'admin.dashboard.open_reports'
%div
= link_to sidekiq_url do
.dashboard__counters__num= number_with_delimiter @queue_backlog
.dashboard__counters__label= t 'admin.dashboard.backlog'
.dashboard__widgets
.dashboard__widgets__users
%div
%h4= t 'admin.dashboard.recent_users'
%ul
- @recent_users.each do |user|
%li= admin_account_link_to(user.account)
.dashboard__widgets__features
%div
%h4= t 'admin.dashboard.features'
%ul
%li
= link_to t('admin.dashboard.feature_registrations'), edit_admin_settings_path
- if @registrations_enabled
%span.pull-right.positive-hint= fa_icon 'check fw'
- else
%span.pull-right.negative-hint= fa_icon 'times fw'
%li
= link_to t('admin.dashboard.feature_invites'), edit_admin_settings_path
- if @invites_enabled
%span.pull-right.positive-hint= fa_icon 'check fw'
- else
%span.pull-right.negative-hint= fa_icon 'times fw'
%li
= link_to t('admin.dashboard.feature_deletions'), edit_admin_settings_path
- if @deletions_enabled
%span.pull-right.positive-hint= fa_icon 'check fw'
- else
%span.pull-right.negative-hint= fa_icon 'times fw'
%li
= link_to t('admin.dashboard.feature_relay'), admin_relays_path
- if @relay_enabled
%span.pull-right.positive-hint= fa_icon 'check fw'
- else
%span.pull-right.negative-hint= fa_icon 'times fw'
.dashboard__widgets__versions
%div
%h4= t 'admin.dashboard.software'
%ul
%li
Mastodon
%span.pull-right= @version
%li
Ruby
%span.pull-right= "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}"
%li
PostgreSQL
%span.pull-right= @database_version
%li
Redis
%span.pull-right= @redis_version
.dashboard__widgets__space
%div
%h4= t 'admin.dashboard.space'
%ul
%li
PostgreSQL
%span.pull-right= number_to_human_size @database_size
%li
Redis
%span.pull-right= number_to_human_size @redis_size
.dashboard__widgets__config
%div
%h4= t 'admin.dashboard.config'
%ul
%li
= t('admin.dashboard.search')
- if @search_enabled
%span.pull-right.positive-hint= fa_icon 'check fw'
- else
%span.pull-right.negative-hint= fa_icon 'times fw'
%li
= t('admin.dashboard.single_user_mode')
- if @single_user_mode
%span.pull-right.positive-hint= fa_icon 'check fw'
- else
%span.pull-right.negative-hint= fa_icon 'times fw'
%li
LDAP
- if @ldap_enabled
%span.pull-right.positive-hint= fa_icon 'check fw'
- else
%span.pull-right.negative-hint= fa_icon 'times fw'
%li
CAS
- if @cas_enabled
%span.pull-right.positive-hint= fa_icon 'check fw'
- else
%span.pull-right.negative-hint= fa_icon 'times fw'
%li
SAML
- if @saml_enabled
%span.pull-right.positive-hint= fa_icon 'check fw'
- else
%span.pull-right.negative-hint= fa_icon 'times fw'
%li
PAM
- if @pam_enabled
%span.pull-right.positive-hint= fa_icon 'check fw'
- else
%span.pull-right.negative-hint= fa_icon 'times fw'
%li
= t 'admin.dashboard.hidden_service'
- if @hidden_service
%span.pull-right.positive-hint= fa_icon 'check fw'
- else
%span.pull-right.negative-hint= fa_icon 'times fw'
.dashboard__widgets__trends
%div
%h4= t 'admin.dashboard.trends'
%ul
- @trending_hashtags.each do |tag|
%li
= link_to "##{tag.name}", web_url("timelines/tag/#{tag.name}")
%span.pull-right= number_with_delimiter(tag.history[0][:accounts].to_i)

View File

@ -34,6 +34,6 @@ class ActivityPub::UpdateDistributionWorker
@account,
serializer: ActivityPub::UpdateSerializer,
adapter: ActivityPub::Adapter
).to_json
).as_json
end
end

View File

@ -206,6 +206,27 @@ en:
update_failed_msg: Could not update that emoji
updated_msg: Emoji successfully updated!
upload: Upload
dashboard:
backlog: backlogged jobs
config: Configuration
feature_deletions: Account deletions
feature_invites: Invite links
feature_registrations: Registrations
feature_relay: Federation relay
features: Features
hidden_service: Federation with hidden services
open_reports: open reports
recent_users: Recent users
search: Full-text search
single_user_mode: Single user mode
software: Software
space: Space usage
title: Dashboard
total_users: users in total
trends: Trends
week_interactions: interactions this week
week_users_active: active this week
week_users_new: users this week
domain_blocks:
add_new: Add new
created_msg: Domain block is now being processed

View File

@ -206,6 +206,26 @@ pl:
update_failed_msg: Nie udało się zaktualizować emoji
updated_msg: Pomyślnie zaktualizowano emoji!
upload: Dodaj
dashboard:
backlog: zaległe zadania
config: Konfiguracja
feature_deletions: Usuwanie kont
feature_invites: Zaproszenia
feature_registrations: Rejestracja
feature_relay: Przekazywanie federacji
features: Możliwości
hidden_service: Federowanie z ukrytymi usługami
open_reports: otwarte zgłoszenia
recent_users: Ostatni użytkownicy
search: Wyszukiwanie pełnego tekstu
single_user_mode: Tryb jednego użytkownika
software: Oprogramowanie
space: Używana powierzchnia
title: Panel administracyjny
total_users: łącznie użytkowników
week_interactions: interakcje w tym tygodniu
week_users_active: aktywni w tym tygodniu
week_users_new: rejestracje w tym tygodniu
domain_blocks:
add_new: Dodaj nową
created_msg: Blokada domen jest przetwarzana
@ -262,6 +282,14 @@ pl:
expired: Wygasłe
title: Filtruj
title: Zaproszenia
relays:
add_new: Dodaj nowy
description_html: "<strong>Przekaźnik federacji</strong> jest pośredniczącym serwerem wymieniającym duże ilości publicznych wpisów pomiędzy serwerami które subskrybują je i publikują na nich. <strong>Pomaga to małym i średnim instancją poznawać nową zawartość z Fediwersum</strong>, co w innym przypadku wymagałoby od użytkowników ręcznego śledzenia osób z innych serwerów."
enable_hint: Jeżeli włączone, Twój serwer zasubskrybuje wszystkie publiczne wpisy z tego przekaźnika i zacznie wysyłać tam publiczne wpisy z tego serwera.
inbox_url: Adres przekaźnika
setup: Skonfiguruj połączenie z przekaźnikiem
status: Stan
title: Przekaźniki
report_notes:
created_msg: Pomyslnie utworzono notatkę moderacyjną.
destroyed_msg: Pomyślnie usunięto notatkę moderacyjną.

View File

@ -39,7 +39,8 @@ SimpleNavigation::Configuration.run do |navigation|
admin.item :email_domain_blocks, safe_join([fa_icon('envelope fw'), t('admin.email_domain_blocks.title')]), admin_email_domain_blocks_url, highlights_on: %r{/admin/email_domain_blocks}, if: -> { current_user.admin? }
end
primary.item :admin, safe_join([fa_icon('cogs fw'), t('admin.title')]), proc { current_user.admin? ? edit_admin_settings_url : admin_custom_emojis_url }, if: proc { current_user.staff? } do |admin|
primary.item :admin, safe_join([fa_icon('cogs fw'), t('admin.title')]), admin_dashboard_url, if: proc { current_user.staff? } do |admin|
admin.item :dashboard, safe_join([fa_icon('tachometer fw'), t('admin.dashboard.title')]), admin_dashboard_url
admin.item :settings, safe_join([fa_icon('cogs fw'), t('admin.settings.title')]), edit_admin_settings_url, if: -> { current_user.admin? }
admin.item :custom_emojis, safe_join([fa_icon('smile-o fw'), t('admin.custom_emojis.title')]), admin_custom_emojis_url, highlights_on: %r{/admin/custom_emojis}
admin.item :relays, safe_join([fa_icon('exchange fw'), t('admin.relays.title')]), admin_relays_url, if: -> { current_user.admin? }, highlights_on: %r{/admin/relays}

View File

@ -127,6 +127,8 @@ Rails.application.routes.draw do
resource :share, only: [:show, :create]
namespace :admin do
get '/dashboard', to: 'dashboard#index'
resources :subscriptions, only: [:index]
resources :domain_blocks, only: [:index, :new, :create, :show, :destroy]
resources :email_domain_blocks, only: [:index, :new, :create, :destroy]
@ -199,13 +201,7 @@ Rails.application.routes.draw do
resources :account_moderation_notes, only: [:create, :destroy]
end
authenticate :user, lambda { |u| u.admin? } do
get '/admin', to: redirect('/admin/settings/edit', status: 302)
end
authenticate :user, lambda { |u| u.moderator? } do
get '/admin', to: redirect('/admin/reports', status: 302)
end
get '/admin', to: redirect('/admin/dashboard', status: 302)
namespace :api do
# PubSubHubbub outgoing subscriptions

View File

@ -8,7 +8,7 @@ const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPl
const OfflinePlugin = require('offline-plugin');
const { publicPath } = require('./configuration.js');
const path = require('path');
const { URL } = require('whatwg-url');
const { URL } = require('url');
let compressionAlgorithm;
try {

View File

@ -2,7 +2,7 @@
"name": "mastodon",
"license": "AGPL-3.0-or-later",
"engines": {
"node": ">=6"
"node": ">=8"
},
"scripts": {
"postversion": "git push --tags",
@ -123,8 +123,7 @@
"webpack-cli": "^3.0.8",
"webpack-manifest-plugin": "^2.0.3",
"webpack-merge": "^4.1.3",
"websocket.js": "^0.1.12",
"whatwg-url": "^6.4.1"
"websocket.js": "^0.1.12"
},
"devDependencies": {
"babel-eslint": "^8.2.6",

View File

@ -4866,10 +4866,6 @@ lodash.mergewith@^4.6.0:
version "4.6.1"
resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz#639057e726c3afbdb3e7d42741caa8d6e4335927"
lodash.sortby@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
lodash.tail@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/lodash.tail/-/lodash.tail-4.1.1.tgz#d2333a36d9e7717c8ad2f7cacafec7c32b444664"
@ -8185,12 +8181,6 @@ tough-cookie@~2.3.0, tough-cookie@~2.3.3:
dependencies:
punycode "^1.4.1"
tr46@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-1.0.1.tgz#a8b13fd6bfd2489519674ccde55ba3693b706d09"
dependencies:
punycode "^2.1.0"
tr46@~0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
@ -8481,7 +8471,7 @@ webidl-conversions@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
webidl-conversions@^4.0.0, webidl-conversions@^4.0.2:
webidl-conversions@^4.0.0:
version "4.0.2"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"
@ -8657,14 +8647,6 @@ whatwg-url@^4.3.0:
tr46 "~0.0.3"
webidl-conversions "^3.0.0"
whatwg-url@^6.4.1:
version "6.5.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-6.5.0.tgz#f2df02bff176fd65070df74ad5ccbb5a199965a8"
dependencies:
lodash.sortby "^4.7.0"
tr46 "^1.0.1"
webidl-conversions "^4.0.2"
whet.extend@~0.9.9:
version "0.9.9"
resolved "https://registry.yarnpkg.com/whet.extend/-/whet.extend-0.9.9.tgz#f877d5bf648c97e5aa542fadc16d6a259b9c11a1"