default
dump_stack() 2023-01-09 13:13:56 +00:00
commit 8d551299d9
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
16 changed files with 1384 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
secrets.nix
hardware-configuration.nix

9
LICENSE Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) 2023 Mikhail Klementev
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

78
configuration.nix Normal file
View File

@ -0,0 +1,78 @@
{ config, pkgs, lib, ... }:
let
secrets = import ./secrets.nix;
in {
imports = [
./hardware-configuration.nix
./mastodon.nix
];
boot.loader = {
efi.canTouchEfiVariables = true;
grub = {
enable = true;
efiSupport = true;
device = "nodev";
mirroredBoots = [{
devices = [ "nodev" ];
path = "/boot-fallback";
}];
};
};
networking = {
hostName = "lor-sh";
hostId = (builtins.substring 0 8 (builtins.readFile "/etc/machine-id"));
useDHCP = false;
interfaces.eno1 = {
ipv4 = secrets.ipv4;
ipv6 = secrets.ipv6;
};
nameservers = [ "1.1.1.1" ];
firewall = {
enable = true;
allowedTCPPorts = [ 80 443 ];
};
};
users.extraUsers.root = {
openssh.authorizedKeys.keys = secrets.pubkeys;
};
services.openssh.enable = true;
environment.systemPackages = with pkgs; [
vim htop git
];
services.postgresql.settings = {
max_connections = "512";
shared_buffers = "4096MB";
};
security.acme = {
acceptTerms = true;
defaults.email = secrets.letsencryptEmail;
};
time.timeZone = "UTC";
system.autoUpgrade = {
enable = true;
allowReboot = true;
};
system.stateVersion = "22.11";
nix = {
optimise.automatic = true;
gc = {
automatic = true;
options = "--delete-older-than 7d";
};
};
}

112
mastodon.nix Normal file
View File

@ -0,0 +1,112 @@
{ config, pkgs, lib, ... }:
let
secrets = import ./secrets.nix;
branding = ''
cp app/javascript/images/logo.svg app/javascript/images/app-icon.svg
PATH=$PATH:${pkgs.librsvg}/bin:${pkgs.imagemagick}/bin \
RAILS_ENV=development rake branding:generate
'';
mastodon-lor-sh = (pkgs.mastodon.overrideAttrs(x: {
patchPhase = branding;
mastodon-modules = pkgs.mastodon.mastodon-modules.overrideAttrs(y: {
patchPhase = branding;
});
})).override {
srcOverride = pkgs.applyPatches {
src = pkgs.fetchgit {
url = "https://github.com/mastodon/mastodon.git";
rev = "v4.0.2"; # "v${pkgs.mastodon.version}";
sha256 = "sha256-gNP/YDioLquxasVpgmCqLnCQx4r/gnIQ3N4YrVcI6+s=";
};
patches = [
./patches/logo.patch
./patches/logo-symbol-wordmark.patch
./patches/mascot.patch
./patches/add-tango-theme.patch
./patches/add-merveilles-theme.patch
./patches/add-black-theme.patch
./patches/themes-config.patch
./patches/fix-mastodon-light-highlight-color.patch
./patches/fix-character-limit.patch
./patches/max-toot-chars-api.patch
./patches/simple-form.patch
];
};
};
sidekiq-manager = pkgs.writers.writePython3 "sidekiq-manager" {} ''
from itertools import permutations
from subprocess import Popen
def sidekiq(queues, connections=16):
mastodon = "${mastodon-lor-sh}"
cmd = [f"{mastodon}/bin/sidekiq", "-r", mastodon]
cmd += ["-c", f"{connections}"]
for q in queues:
cmd += ['-q', q]
return Popen(cmd)
procs = [sidekiq(['mailers', 'pull', 'scheduler'])]
queues = ['default', 'push', 'ingress']
procs += [sidekiq(qs) for qs in permutations(queues)]
for p in procs:
p.wait()
'';
in {
# Until merge of https://github.com/NixOS/nixpkgs/pull/202408
systemd.services.mastodon-sidekiq.serviceConfig.ExecStart =
lib.mkForce "${sidekiq-manager}";
# https://github.com/mperham/sidekiq/wiki/Memory#bloat
systemd.services.mastodon-sidekiq.environment.MALLOC_ARENA_MAX = "2";
services.mastodon = {
enable = true;
package = mastodon-lor-sh;
localDomain = "lor.sh";
configureNginx = true;
smtp = {
createLocally = false;
authenticate = true;
host = "smtp.eu.mailgun.org";
port = 587;
fromAddress = "Mastodon <mastodon@m.lor.sh>";
user = "mastodon@m.lor.sh";
passwordFile = builtins.toFile "smtp-password" secrets.smtpPassword;
};
vapidPublicKeyFile = builtins.toFile "vapidPublicKey" secrets.vapidPublicKey;
secretKeyBaseFile = builtins.toFile "secretKeyBase" secrets.secretKeyBase;
otpSecretFile = builtins.toFile "otpSecret" secrets.otpSecret;
vapidPrivateKeyFile = builtins.toFile "vapidPrivateKey" secrets.vapidPrivateKey;
extraConfig = {
S3_ENABLED = "true";
S3_PROTOCOL = "https";
S3_BUCKET = "lor-sh";
S3_REGION = "eu-central-1";
S3_HOSTNAME = "s3.eu-central-1.wasabisys.com";
S3_ENDPOINT = "https://s3.eu-central-1.wasabisys.com/lor-sh";
S3_ALIAS_HOST = "s3.eu-central-1.wasabisys.com/lor-sh/lor-sh";
AWS_ACCESS_KEY_ID = secrets.AWS_ACCESS_KEY_ID;
AWS_SECRET_ACCESS_KEY = secrets.AWS_SECRET_ACCESS_KEY;
DEEPL_API_KEY = secrets.DEEPL_API_KEY;
DEEPL_PLAN = "pro";
};
};
}

View File

@ -0,0 +1,9 @@
diff --git a/app/javascript/styles/black.scss b/app/javascript/styles/black.scss
new file mode 100644
index 000000000..5598dbea0
--- /dev/null
+++ b/app/javascript/styles/black.scss
@@ -0,0 +1,3 @@
+$ui-base-color: #000000;
+
+@import 'application';

View File

@ -0,0 +1,10 @@
diff --git a/app/javascript/styles/merveilles.scss b/app/javascript/styles/merveilles.scss
new file mode 100644
index 000000000..5147ae626
--- /dev/null
+++ b/app/javascript/styles/merveilles.scss
@@ -0,0 +1,4 @@
+$ui-base-color: #222222;
+$ui-highlight-color: #333333;
+
+@import "application";

View File

@ -0,0 +1,10 @@
diff --git a/app/javascript/styles/tango.scss b/app/javascript/styles/tango.scss
new file mode 100644
index 000000000..9699d17b5
--- /dev/null
+++ b/app/javascript/styles/tango.scss
@@ -0,0 +1,4 @@
+$ui-base-color: #2f3436;
+$ui-highlight-color: #5c90c7;
+
+@import 'application';

View File

@ -0,0 +1,35 @@
diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js
index 6a65f44da..d67e29db3 100644
--- a/app/javascript/mastodon/features/compose/components/compose_form.js
+++ b/app/javascript/mastodon/features/compose/components/compose_form.js
@@ -90,7 +90,7 @@ class ComposeForm extends ImmutablePureComponent {
const fulltext = this.getFulltextForCharacterCounting();
const isOnlyWhitespace = fulltext.length !== 0 && fulltext.trim().length === 0;
- return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > 500 || (isOnlyWhitespace && !anyMedia));
+ return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > 100500 || (isOnlyWhitespace && !anyMedia));
}
handleSubmit = (e) => {
@@ -277,7 +277,7 @@ class ComposeForm extends ImmutablePureComponent {
</div>
<div className='character-counter__wrapper'>
- <CharacterCounter max={500} text={this.getFulltextForCharacterCounting()} />
+ <CharacterCounter max={100500} text={this.getFulltextForCharacterCounting()} />
</div>
</div>
diff --git a/app/validators/status_length_validator.rb b/app/validators/status_length_validator.rb
index e107912b7..1e374a84d 100644
--- a/app/validators/status_length_validator.rb
+++ b/app/validators/status_length_validator.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class StatusLengthValidator < ActiveModel::Validator
- MAX_CHARS = 500
+ MAX_CHARS = 100500
URL_PLACEHOLDER_CHARS = 23
URL_PLACEHOLDER = 'x' * 23

View File

@ -0,0 +1,13 @@
diff --git a/app/javascript/styles/mastodon-light/variables.scss b/app/javascript/styles/mastodon-light/variables.scss
index cae065878..29de2a9b3 100644
--- a/app/javascript/styles/mastodon-light/variables.scss
+++ b/app/javascript/styles/mastodon-light/variables.scss
@@ -5,7 +5,7 @@ $white: #ffffff;
$classic-base-color: #282c37;
$classic-primary-color: #9baec8;
$classic-secondary-color: #d9e1e8;
-$classic-highlight-color: #6364ff;
+$classic-highlight-color: #5c90c7;
// Differences
$success-green: lighten(#3c754d, 8%);

File diff suppressed because one or more lines are too long

485
patches/logo.patch Normal file

File diff suppressed because one or more lines are too long

477
patches/mascot.patch Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,21 @@
diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb
index 5ae1099d0..c9c76c700 100644
--- a/app/serializers/rest/instance_serializer.rb
+++ b/app/serializers/rest/instance_serializer.rb
@@ -11,11 +11,16 @@ class REST::InstanceSerializer < ActiveModel::Serializer
attributes :domain, :title, :version, :source_url, :description,
:usage, :thumbnail, :languages, :configuration,
+ :max_toot_chars,
:registrations
has_one :contact, serializer: ContactSerializer
has_many :rules, serializer: REST::RuleSerializer
+ def max_toot_chars
+ StatusLengthValidator::MAX_CHARS
+ end
+
def thumbnail
if object.thumbnail
{

39
patches/simple-form.patch Normal file
View File

@ -0,0 +1,39 @@
diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml
index 6edf7b4e9..fe196a387 100644
--- a/config/locales/simple_form.en.yml
+++ b/config/locales/simple_form.en.yml
@@ -99,7 +99,7 @@ en:
imports:
data: CSV file exported from another Mastodon server
invite_request:
- text: This will help us review your application
+ text: This will help us review your application. Make sure you read the rules before writing anything here
ip_block:
comment: Optional. Remember why you added this rule.
expires_in: IP addresses are a finite resource, they are sometimes shared and often change hands. For this reason, indefinite IP blocks are not recommended.
diff --git a/config/locales/simple_form.fr.yml b/config/locales/simple_form.fr.yml
index 3b2d30aae..fdc802eab 100644
--- a/config/locales/simple_form.fr.yml
+++ b/config/locales/simple_form.fr.yml
@@ -99,7 +99,7 @@ fr:
imports:
data: Un fichier CSV généré par un autre serveur de Mastodon
invite_request:
- text: Cela nous aidera à considérer votre demande
+ text: Cela nous aidera à considérer votre demande. Assurez-vous de lire les règles avant d'écrire quoi que ce soit ici
ip_block:
comment: Optionnel. Pour ne pas oublier pourquoi vous avez ajouté cette règle.
expires_in: Les adresses IP sont une ressource finie, elles sont parfois partagées et changent souvent de mains. Pour cette raison, les blocages dIP indéfiniment ne sont pas recommandés.
diff --git a/config/locales/simple_form.ru.yml b/config/locales/simple_form.ru.yml
index e95b22377..7854d633a 100644
--- a/config/locales/simple_form.ru.yml
+++ b/config/locales/simple_form.ru.yml
@@ -82,7 +82,7 @@ ru:
imports:
data: Файл CSV, экспортированный с другого узла Mastodon.
invite_request:
- text: Это поможет нам рассмотреть вашу заявку
+ text: Это поможет нам рассмотреть вашу заявку. Перед тем, как писать что-либо здесь, обязательно прочтите правила
ip_block:
comment: Необязательно. Заметка на будущее, почему вы добавили это правило.
expires_in: IP адреса — весьма ограниченный ресурс, иногда они разделяются между абонентами и часто меняют владельца. По этой причине блокировки на неопределённые сроки не рекомендуются.

View File

@ -0,0 +1,11 @@
diff --git a/config/themes.yml b/config/themes.yml
index 9c21c9459..49da04fde 100644
--- a/config/themes.yml
+++ b/config/themes.yml
@@ -1,3 +1,6 @@
default: styles/application.scss
contrast: styles/contrast.scss
mastodon-light: styles/mastodon-light.scss
+tango: styles/tango.scss
+black: styles/black.scss
+merveilles: styles/merveilles.scss

36
secrets.nix.example Normal file
View File

@ -0,0 +1,36 @@
{
pubkeys = [
""
];
smtpPassword = "";
vapidPublicKey = "";
secretKeyBase = "";
otpSecret = "";
vapidPrivateKey = "";
AWS_ACCESS_KEY_ID = "";
AWS_SECRET_ACCESS_KEY = "";
DEEPL_API_KEY = "";
letsencryptEmail = "";
ipv4 = {
addresses = [
{ address = ""; prefixLength = 26; }
];
routes = [
{ address = "0.0.0.0"; prefixLength = 0; via = ""; }
];
};
ipv6 = {
addresses = [
{ address = ""; prefixLength = 64; }
];
routes = [
{ address = "::"; prefixLength = 0; via = "fe80::1"; }
];
};
}