Difference between revisions of "Mastodon/Hosting"

From NixNet
m (→‎Adding it to the API: generalise the steps)
m (add category)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
[[Category:Admin guides]]
 
{{admin guides}}
 
{{admin guides}}
 
{{unfinished}}
 
{{unfinished}}
Line 13: Line 14:
  
 
===== Adding it to the API =====
 
===== Adding it to the API =====
(so apps like [https://tusky.app/ Tusky] don’t keep it at 500)  
+
 
 +
''(so apps like [https://tusky.app/ Tusky] don’t keep it at 500)''
 +
 
 +
{{Note|This doesn't appear to work any more. If you've figured it out, feel free to update the docs or [https://nixnet.services/contact let me know] and I will.|warn}}
  
 
# In <code>app/serializers/rest/instance_serializer.rb</code>, add <code>:max_toot_chars</code> to the end of the <code>attributes</code> section. Make sure you have a <code>,</code> before it.
 
# In <code>app/serializers/rest/instance_serializer.rb</code>, add <code>:max_toot_chars</code> to the end of the <code>attributes</code> section. Make sure you have a <code>,</code> before it.

Latest revision as of 21:22, 16 September 2021

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/validators/status_length_validator.rb with your desired limit
  2. Restart the Mastodon processes
Adding it to the API

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

This doesn't appear to work any more. If you've figured it out, feel free to update the docs or let me know and I will.
  1. In app/serializers/rest/instance_serializer.rb, add :max_toot_chars to the end of the attributes section. Make sure you have a , before it.
  2. Add the following snippet before the private section towards the bottom of the file
  def max_toot_chars
    <desired-limit>
  end
  1. Restart the Mastodon processes

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-*