Mastodon/Hosting

From NixNet
< Mastodon
Revision as of 07:23, 31 July 2020 by Amolith (talk | contribs) (→‎Character Count: update the toots section)
This article is part of a series of guides that describe NixNet's setup in excruciating detail. If you would like to follow them, please start at the Infrastructure page.
Caution: this guide is not finished yet; following it may leave you with an unuseable machine. To be notified of updates, please create an account and add it to your watchlist.

Configuration

Character Count

Character limits really annoy me so this is a page documenting how I increased them on my Mastodon instance.

Assume we’re in path/to/your/mastodon/live for this whole page.

Toots

  1. Replace every instance of 500 in app/javascript/mastodon/features/compose/components/compose_form.js and app/validators/status_length_validator.rb
  2. Restart the Mastodon processes
Adding it to the API

(so apps like Tusky don’t keep it at 500)

  1. In line 8 of app/serializers/rest/instance_serializer.rb, add :max_toot_chars to the end of the line. Make sure you have a , after :registrations
  2. Add the following snippet in between the last two lines (62 and 63)
  def max_toot_chars
    4096
  end
  1. Step 2 above

Credit to @f0x for finding this one and documenting it in their bio.

Bios

  1. In app/models/account.rb line 78, change 160 to whatever character limit you want
  2. In app/views/settings/profiles/show.html.haml line 10, change 160 to whatever limit you want
  3. Step 2 in the first bit

Credit to @f0x again

Display names

  1. In app/models/account.rb line 77, change 30 to whatever you want
  2. In app/views/settings/profiles/show.html.haml line 9, change 30 to whatever you want
  3. Step 2 in the first bit

Credit to @f0x again

Number of poll options

  1. In app/javascript/mastodon/features/compose/components/poll_form.js line 92, remove the = from index <= 1
  2. In app/validators/poll_validator.rb lines 4, 5, and 12, change the MAX_OPTIONS to however many you’d like (I set 100), MAX_OPTION_CHARS to whatever you’d like (I chose 2000 just because ¯\_(ツ)_/¯), and add = to poll.options.size > 1 so it lookes like poll.options.size >= 1

Credit to @ben for showing me the commits they made to change it

Themes

I followed the guide on the mastomods GitHub repo. I recommend using it as well because the information here might eventually be deprecated and I won’t have updated it 😉

Some great themes can be found on GitHub from Toot.café and Witches.town

  1. Add whatever CSS themes you want to path/to/mastodon/live/app/javascript/styles/
  2. List them in path/to/mastodon/live/config/themes.yml (👈 link to default)
  3. Optional - add a more human-readable name for them in path/to/mastodon/config/locales/[lang.yml] (👈 again, link to default)
  4. Compile the theme assets with RAILS_ENV=production bundle exec rails assets:precompile
  5. Restart with sudo systemctl restart mastodon-*

Making your own theme

If you just want to change colours, the easiest way is to copy a theme like Toot.café’s , change the name, modify the hex colour values to whatever you want, then follow steps 2-5 above.

For changing icons and things like that, best practise is to . . .

  1. Follow this

Tor support

  1. Install tor (instructions for Debian-based systems)
  2. Install Privoxy (on Debian, sudo apt install privoxy)
  3. Add forward-socks4a .onion localhost:9050 . (don’t forget the .) to /etc/privoxy/config
  4. Add the following text to the bottom of .env.production http_proxy=http://127.0.0.1:8118 ALLOW_ACCESS_TO_HIDDEN_SERVICE=true
  5. Run these as root 👇
su - mastodon
RAILS_ENV=production bundle exec rails assets:precompile
exit
systemctl restart mastodon-*