Compare commits

..

No commits in common. "521b43393350be16fbd1aa003607480c2442f3eb" and "80cd001e0aa876b690c6862e2f9cbb945074f2ff" have entirely different histories.

9 changed files with 29 additions and 51 deletions

View File

@ -1,17 +1,20 @@
# For details, see https://github.com/devcontainers/images/tree/main/src/ruby # For details, see https://github.com/devcontainers/images/tree/main/src/ruby
FROM mcr.microsoft.com/devcontainers/ruby:1-3.3-bookworm FROM mcr.microsoft.com/devcontainers/ruby:1-3.3-bookworm
# Update existing node version, keep in sync with .nvmrc # Install Rails
# RUN gem install rails webdrivers
ARG NODE_VERSION="20" ARG NODE_VERSION="20"
RUN . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1 RUN . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1
# Install additional OS packages # [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && \ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
export DEBIAN_FRONTEND=noninteractive && \ && apt-get -y install --no-install-recommends libicu-dev libidn11-dev ffmpeg imagemagick libvips42 libpam-dev
apt-get -y install --no-install-recommends libicu-dev libidn11-dev ffmpeg imagemagick libvips42 libpam-dev
# Install global node packages # [Optional] Uncomment this line to install additional gems.
RUN gem install foreman
# [Optional] Uncomment this line to install global node packages.
RUN . /usr/local/share/nvm/nvm.sh && corepack enable 2>&1 RUN . /usr/local/share/nvm/nvm.sh && corepack enable 2>&1
# Move welcome message to where VS Code expects it
COPY welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt COPY welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt

View File

@ -1,6 +1,6 @@
{ {
"name": "Mastodon on GitHub Codespaces", "name": "Mastodon on GitHub Codespaces",
"dockerComposeFile": "../compose.yaml", "dockerComposeFile": "../docker-compose.yml",
"service": "app", "service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

View File

@ -1,6 +1,6 @@
{ {
"name": "Mastodon on local machine", "name": "Mastodon on local machine",
"dockerComposeFile": "compose.yaml", "dockerComposeFile": "docker-compose.yml",
"service": "app", "service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

View File

@ -102,35 +102,26 @@ To set up **MacOS** for native development, complete the following steps:
### Docker ### Docker
For production hosting and deployment with **Docker**, use the `Dockerfile` and For production hosting and deployment with **Docker**, use the `Dockerfile` and
`docker-compose.yml` in the project root directory. `docker-compose.yml` in the project root directory. To create a local
development environment with **Docker**, complete the following steps:
For local development, install and launch [Docker], and run: - Install Docker Desktop
- Run `docker compose -f .devcontainer/docker-compose.yml up -d`
- Run `docker compose -f .devcontainer/docker-compose.yml exec app bin/setup`
- Finally, run `docker compose -f .devcontainer/docker-compose.yml exec app bin/dev`
```shell If you are using an IDE with [support for the Development Container specification](https://containers.dev/supporting), it will run the above `docker compose` commands automatically. For **Visual Studio Code** this requires the [Dev Container extension](https://containers.dev/supporting#dev-containers).
docker compose -f .devcontainer/compose.yaml up -d
docker compose -f .devcontainer/compose.yaml exec app bin/setup
docker compose -f .devcontainer/compose.yaml exec app bin/dev
```
### Dev Containers
Within IDEs that support the [Development Containers] specification, start the
"Mastodon on local machine" container from the editor. The necessary `docker
compose` commands to build and setup the container should run automatically. For
**Visual Studio Code** this requires installing the [Dev Container extension].
### GitHub Codespaces ### GitHub Codespaces
[GitHub Codespaces] provides a web-based version of VS Code and a cloud hosted To get you coding in just a few minutes, GitHub Codespaces provides a web-based version of Visual Studio Code and a cloud-hosted development environment fully configured with the software needed for this project..
development environment configured with the software needed for this project.
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)][codespace] - Click this button to create a new codespace:<br>
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=52281283&devcontainer_path=.devcontainer%2Fcodespaces%2Fdevcontainer.json)
- Click the button to create a new codespace, and confirm the options - Wait for the environment to build. This will take a few minutes.
- Wait for the environment to build (takes a few minutes) - When the editor is ready, run `bin/dev` in the terminal.
- When the editor is ready, run `bin/dev` in the terminal - After a few seconds, a popup will appear with a button labeled _Open in Browser_. This will open Mastodon.
- Wait for an _Open in Browser_ prompt. This will open Mastodon - On the _Ports_ tab, right click on the “stream” row and select _Port visibility__Public_.
- On the _Ports_ tab "stream" setting change _Port visibility_ → _Public_
## Contributing ## Contributing
@ -149,9 +140,3 @@ This program is free software: you can redistribute it and/or modify it under th
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
[codespace]: https://codespaces.new/mastodon/mastodon?quickstart=1&devcontainer_path=.devcontainer%2Fcodespaces%2Fdevcontainer.json
[Dev Container extension]: https://containers.dev/supporting#dev-containers
[Development Containers]: https://containers.dev/supporting
[Docker]: https://docs.docker.com
[GitHub Codespaces]: https://docs.github.com/en/codespaces

View File

@ -41,8 +41,8 @@ class VideoMetadataExtractor
@colorspace = video_stream[:pix_fmt] @colorspace = video_stream[:pix_fmt]
@width = video_stream[:width] @width = video_stream[:width]
@height = video_stream[:height] @height = video_stream[:height]
@frame_rate = parse_framerate(video_stream[:avg_frame_rate]) @frame_rate = video_stream[:avg_frame_rate] == '0/0' ? nil : Rational(video_stream[:avg_frame_rate])
@r_frame_rate = parse_framerate(video_stream[:r_frame_rate]) @r_frame_rate = video_stream[:r_frame_rate] == '0/0' ? nil : Rational(video_stream[:r_frame_rate])
# For some video streams the frame_rate reported by `ffprobe` will be 0/0, but for these streams we # For some video streams the frame_rate reported by `ffprobe` will be 0/0, but for these streams we
# should use `r_frame_rate` instead. Video screencast generated by Gnome Screencast have this issue. # should use `r_frame_rate` instead. Video screencast generated by Gnome Screencast have this issue.
@frame_rate ||= @r_frame_rate @frame_rate ||= @r_frame_rate
@ -55,10 +55,4 @@ class VideoMetadataExtractor
@invalid = true if @metadata.key?(:error) @invalid = true if @metadata.key?(:error)
end end
def parse_framerate(raw)
Rational(raw)
rescue ZeroDivisionError
nil
end
end end

View File

@ -12,8 +12,6 @@ module Paperclip
attachment.instance.blurhash = Blurhash.encode(width, height, data, **(options[:blurhash] || {})) attachment.instance.blurhash = Blurhash.encode(width, height, data, **(options[:blurhash] || {}))
@file @file
rescue Vips::Error => e
raise Paperclip::Error, "Error while generating blurhash for #{@basename}: #{e}"
end end
private private

View File

@ -69,8 +69,6 @@ module Paperclip
attachment.instance.file.instance_write(:meta, (attachment.instance.file.instance_read(:meta) || {}).merge(meta)) attachment.instance.file.instance_write(:meta, (attachment.instance.file.instance_read(:meta) || {}).merge(meta))
@file @file
rescue Vips::Error => e
raise Paperclip::Error, "Error while extracting colors for #{@basename}: #{e}"
end end
private private

View File

@ -68,7 +68,7 @@ module Paperclip
end end
dst dst
rescue Vips::Error, Terrapin::ExitStatusError => e rescue Terrapin::ExitStatusError => e
raise Paperclip::Error, "Error while optimizing #{@basename}: #{e}" raise Paperclip::Error, "Error while optimizing #{@basename}: #{e}"
rescue Terrapin::CommandNotFoundError rescue Terrapin::CommandNotFoundError
raise Paperclip::Errors::CommandNotFoundError, 'Could not run the `ffmpeg` command. Please install ffmpeg.' raise Paperclip::Errors::CommandNotFoundError, 'Could not run the `ffmpeg` command. Please install ffmpeg.'