喂饭级Mastodon嘟文字数修改和长嘟文折叠

带代码的纯喂饭

适用情况

按文档部署的,没用docker。用docker的可以参考这位

嘟文字数修改

  1. 以mastodon用户(如果当初是按文档建在mastodon用户下的话)进入live
    1. su - mastodon
    2. cd live
  2. 编辑 status_length_validator.rb
    1. nano app/validators/status_length_validator.rb
    2. MAX_CHARS = 500 改成想要的字数,并保存
  3. 编译前端
    1. RAILS_ENV=production bundle exec rails assets:precompile
  4. 重启
    1. su -
    2. systemctl restart mastodon-web mastodon-sidekiq mastodon-streaming

长嘟文折叠

  1. 同以上1

  2. 编辑mastodon-light.scss (也可能是mastodon.scss

    1. cd app/javascript/styles

    2. nano mastodon-light.scss

    3. 添加以下代码并保存

       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      
      .status__content {
          max-height: 250px; /* 设置最大高度,可调整,我决定250或者300就挺好 */
          overflow: hidden;
          position: relative;
      }
      
      .status__content::after {
          content: '... 点击展开';
          display: block;
          text-align: center;
          background: linear-gradient(to top, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
          position: absolute;
          bottom: 0;
          width: 100%;
          height: 30px;
          line-height: 30px;
          cursor: pointer;
      }
      
      .status__content.expanded {
          max-height: none;
      }
      
  3. 同上。

  4. 同上。

Licensed under CC BY-NC-SA 4.0
发表了10篇文章 · 总计20.19k字
本博客已稳定运行
Built with Hugo
主题 StackJimmy 设计