Code Monkey home page Code Monkey logo

sorry's Introduction

图片

代码库

├── Gemfile
├── Gemfile.lock
├── LICENSE
├── public                  # 静态文件目录
├── README.md
├── resource                # 模板文件目录,里边存放用于生成gif的文件
├── site_config.yml         # 站点配置文件
├── src                     # 这里就是源代码
└── temp                    # 把临时文件安放在这里

部署

首先,机器上得安装好ruby 💎

接下来:

# 安装bundler
gem install bundler

# [可选] 使用国内镜像
gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/

# [可选] Linux服务器一般需要安装中文字体
apt install language-pack-zh-hans
apt install ttf-wqy-microhei 

# 安装编译依赖
apt install ruby-dev build-essential

# 安装ffmpeg
apt install ffmpeg

# 安装依赖
bundle install

# 运行
ruby src/sorry.rb

# 生产环境
APP_ENV=production ruby src/sorry.rb

[可选] 使用PM2监控&自动重启

npm install pm2 -g

pm2 start process.yml --env production

定时清除缓存

crontab -e

# 在每小时的第10分钟 清除700分钟以前的gif

10  *  *   *   *     find /root/sorry/public/cache -name '*.gif' -mmin +700  -exec rm {} \;       

适配新Gif

目前,想要适配新的gif,需要改动3个文件

public/index.html
resource/sorry.mp4
resource/sorry.erb

其中

index.html  按照句子的多少删掉或者增加<input>即可
sorry.mp4   替换成新视频
sorry.erb   替换成新的字幕模板

字幕模板sorry.erb

首先使用aegisub为模板视频创建字幕,保存为sorry.ass(aegisub教程可以看这个 https://tieba.baidu.com/p/1360405931图片

然后把文本替换成模板字符串 <%= sentences[n] %> 图片

最后保存为sorry.erb

现在这个网站就可以制作新的gif了

如果你不熟悉aegisub的使用,也可以发个issue,同时附上模板视频🎞️

TODO

  • 重新设计主页
  • 重新设计404页面
  • 把gif的渲染弄成队列,提高响应速度
  • 定时删除缓存,不然有多少硬盘空间也不够用
  • 写个脚本,自动配置新的gif
  • 写测试

sorry's People

Contributors

xtyxtyx avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.