mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Compare commits
No commits in common. "dfa9843ac85d04e1facb2f757fd9288d8bb9fb2c" and "cb868228bde5351b79041f341a151bb08118d31f" have entirely different histories.
dfa9843ac8
...
cb868228bd
13 changed files with 63 additions and 98 deletions
|
@ -1,14 +1,16 @@
|
|||
# For details, see https://github.com/devcontainers/images/tree/main/src/ruby
|
||||
FROM mcr.microsoft.com/devcontainers/ruby:0-3.2-bullseye
|
||||
# [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.1, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.1-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.1-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
|
||||
ARG VARIANT=3.1-bullseye
|
||||
FROM mcr.microsoft.com/vscode/devcontainers/ruby:${VARIANT}
|
||||
|
||||
# Install Rails
|
||||
# RUN gem install rails webdrivers
|
||||
|
||||
# Default value to allow debug server to serve content over GitHub Codespace's port forwarding service
|
||||
# The value is a comma-separated list of allowed domains
|
||||
ENV RAILS_DEVELOPMENT_HOSTS=".githubpreview.dev,.preview.app.github.dev,.app.github.dev"
|
||||
ENV RAILS_DEVELOPMENT_HOSTS=".githubpreview.dev"
|
||||
|
||||
ARG NODE_VERSION="16"
|
||||
# [Choice] Node.js version: lts/*, 18, 16, 14
|
||||
ARG NODE_VERSION="lts/*"
|
||||
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"
|
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages.
|
||||
|
@ -20,5 +22,3 @@ RUN gem install foreman
|
|||
|
||||
# [Optional] Uncomment this line to install global node packages.
|
||||
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g yarn" 2>&1
|
||||
|
||||
COPY welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt
|
||||
|
|
|
@ -1,13 +1,30 @@
|
|||
// For more details, see https://aka.ms/devcontainer.json.
|
||||
{
|
||||
"name": "Mastodon",
|
||||
"dockerComposeFile": "docker-compose.yml",
|
||||
"service": "app",
|
||||
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
|
||||
"workspaceFolder": "/mastodon",
|
||||
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
// Configure properties specific to VS Code.
|
||||
"vscode": {
|
||||
// Set *default* container specific settings.json values on container create.
|
||||
"settings": {},
|
||||
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": [
|
||||
"EditorConfig.EditorConfig",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"rebornix.Ruby",
|
||||
"webben.browserslist"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/sshd:1": {}
|
||||
"ghcr.io/devcontainers/features/sshd:1": {
|
||||
"version": "latest"
|
||||
}
|
||||
},
|
||||
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
|
@ -16,16 +33,7 @@
|
|||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
"postCreateCommand": ".devcontainer/post-create.sh",
|
||||
"waitFor": "postCreateCommand",
|
||||
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
// Configure properties specific to VS Code.
|
||||
"vscode": {
|
||||
// Set *default* container specific settings.json values on container create.
|
||||
"settings": {},
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": ["EditorConfig.EditorConfig", "webben.browserslist"]
|
||||
}
|
||||
}
|
||||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
||||
"remoteUser": "vscode"
|
||||
}
|
||||
|
|
|
@ -5,8 +5,15 @@ services:
|
|||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
# Update 'VARIANT' to pick a version of Ruby: 3, 3.1, 3.0, 2, 2.7, 2.6
|
||||
# Append -bullseye or -buster to pin to an OS version.
|
||||
# Use -bullseye variants on local arm64/Apple Silicon.
|
||||
VARIANT: '3.0-bullseye'
|
||||
# Optional Node.js version to install
|
||||
NODE_VERSION: '16'
|
||||
volumes:
|
||||
- ../..:/workspaces:cached
|
||||
- ..:/mastodon:cached
|
||||
environment:
|
||||
RAILS_ENV: development
|
||||
NODE_ENV: development
|
||||
|
@ -26,6 +33,7 @@ services:
|
|||
networks:
|
||||
- external_network
|
||||
- internal_network
|
||||
user: vscode
|
||||
|
||||
db:
|
||||
image: postgres:14-alpine
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
👋 Welcome to "Mastodon" in GitHub Codespaces!
|
||||
|
||||
🛠️ Your environment is fully setup with all the required software.
|
||||
|
||||
🔍 To explore VS Code to its fullest, search using the Command Palette (Cmd/Ctrl + Shift + P or F1).
|
||||
|
||||
📝 Edit away, run your app as usual, and we'll automatically make it available for you to access.
|
||||
|
|
@ -19,6 +19,7 @@ AllCops:
|
|||
NewCops: enable
|
||||
Exclude:
|
||||
- db/schema.rb
|
||||
- 'app/views/**/*'
|
||||
- 'config/**/*'
|
||||
- 'bin/*'
|
||||
- 'Rakefile'
|
||||
|
|
|
@ -144,7 +144,7 @@ GEM
|
|||
bootsnap (1.16.0)
|
||||
msgpack (~> 1.2)
|
||||
brakeman (5.4.0)
|
||||
browser (5.3.1)
|
||||
browser (4.2.0)
|
||||
brpoplpush-redis_script (0.1.3)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.5)
|
||||
redis (>= 1.0, < 6)
|
||||
|
|
10
README.md
10
README.md
|
@ -85,16 +85,6 @@ A **Vagrant** configuration is included for development purposes. To use it, com
|
|||
- Run `vagrant ssh -c "cd /vagrant && foreman start"`
|
||||
- Open `http://mastodon.local` in your browser
|
||||
|
||||
### Getting Started with GitHub Codespaces
|
||||
|
||||
To get started, create a codespace for this repository by clicking this 👇
|
||||
|
||||
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=52281283)
|
||||
|
||||
A codespace will open in a web-based version of Visual Studio Code. The [dev container](.devcontainer/devcontainer.json) is fully configured with software needed for this project.
|
||||
|
||||
**Note**: Dev containers is an open spec which is supported by [GitHub Codespaces](https://github.com/codespaces) and [other tools](https://containers.dev/supporting).
|
||||
|
||||
## Contributing
|
||||
|
||||
Mastodon is **free, open-source software** licensed under **AGPLv3**.
|
||||
|
|
|
@ -5,7 +5,7 @@ RSS::Builder.build do |doc|
|
|||
doc.image(full_asset_url(@account.avatar.url(:original)), display_name(@account), params[:tag].present? ? short_account_tag_url(@account, params[:tag]) : short_account_url(@account))
|
||||
doc.last_build_date(@statuses.first.created_at) if @statuses.any?
|
||||
doc.icon(full_asset_url(@account.avatar.url(:original)))
|
||||
doc.generator("Mastodon v#{Mastodon::Version}")
|
||||
doc.generator("Mastodon v#{Mastodon::Version.to_s}")
|
||||
|
||||
@statuses.each do |status|
|
||||
doc.item do |item|
|
||||
|
@ -18,12 +18,12 @@ RSS::Builder.build do |doc|
|
|||
item.enclosure(full_asset_url(media.file.url(:original, false)), media.file.content_type, media.file.size)
|
||||
end
|
||||
|
||||
status.ordered_media_attachments.each do |media_attachment|
|
||||
item.media_content(full_asset_url(media_attachment.file.url(:original, false)), media_attachment.file.content_type, media_attachment.file.size) do |media_content|
|
||||
media_content.medium(media_attachment.gifv? ? 'image' : media_attachment.type.to_s)
|
||||
status.ordered_media_attachments.each do |media|
|
||||
item.media_content(full_asset_url(media.file.url(:original, false)), media.file.content_type, media.file.size) do |media_content|
|
||||
media_content.medium(media.gifv? ? 'image' : media.type.to_s)
|
||||
media_content.rating(status.sensitive? ? 'adult' : 'nonadult')
|
||||
media_content.description(media_attachment.description) if media_attachment.description.present?
|
||||
media_content.thumbnail(media_attachment.thumbnail.url(:original, false)) if media_attachment.thumbnail?
|
||||
media_content.description(media.description) if media.description.present?
|
||||
media_content.thumbnail(media.thumbnail.url(:original, false)) if media.thumbnail?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ RSS::Builder.build do |doc|
|
|||
doc.description(I18n.t('rss.descriptions.tag', hashtag: @tag.display_name))
|
||||
doc.link(tag_url(@tag))
|
||||
doc.last_build_date(@statuses.first.created_at) if @statuses.any?
|
||||
doc.generator("Mastodon v#{Mastodon::Version}")
|
||||
doc.generator("Mastodon v#{Mastodon::Version.to_s}")
|
||||
|
||||
@statuses.each do |status|
|
||||
doc.item do |item|
|
||||
|
@ -16,12 +16,12 @@ RSS::Builder.build do |doc|
|
|||
item.enclosure(full_asset_url(media.file.url(:original, false)), media.file.content_type, media.file.size)
|
||||
end
|
||||
|
||||
status.ordered_media_attachments.each do |media_attachment|
|
||||
item.media_content(full_asset_url(media_attachment.file.url(:original, false)), media_attachment.file.content_type, media_attachment.file.size) do |media_content|
|
||||
media_content.medium(media_attachment.gifv? ? 'image' : media_attachment.type.to_s)
|
||||
status.ordered_media_attachments.each do |media|
|
||||
item.media_content(full_asset_url(media.file.url(:original, false)), media.file.content_type, media.file.size) do |media_content|
|
||||
media_content.medium(media.gifv? ? 'image' : media.type.to_s)
|
||||
media_content.rating(status.sensitive? ? 'adult' : 'nonadult')
|
||||
media_content.description(media_attachment.description) if media_attachment.description.present?
|
||||
media_content.thumbnail(media_attachment.thumbnail.url(:original, false)) if media_attachment.thumbnail?
|
||||
media_content.description(media.description) if media.description.present?
|
||||
media_content.thumbnail(media.thumbnail.url(:original, false)) if media.thumbnail?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -9,4 +9,4 @@ doc << Ox::Element.new('XRD').tap do |xrd|
|
|||
end
|
||||
end
|
||||
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>#{Ox.dump(doc, effort: :tolerant)}".force_encoding('UTF-8')
|
||||
('<?xml version="1.0" encoding="UTF-8"?>' + Ox.dump(doc, effort: :tolerant)).force_encoding('UTF-8')
|
||||
|
|
|
@ -5,7 +5,6 @@ default: &default
|
|||
connect_timeout: 15
|
||||
encoding: unicode
|
||||
sslmode: <%= ENV['DB_SSLMODE'] || "prefer" %>
|
||||
application_name: ''
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
|
|
|
@ -1448,7 +1448,6 @@ en:
|
|||
electron: Electron
|
||||
firefox: Firefox
|
||||
generic: Unknown browser
|
||||
huawei_browser: Huawei Browser
|
||||
ie: Internet Explorer
|
||||
micro_messenger: MicroMessenger
|
||||
nokia: Nokia S40 Ovi Browser
|
||||
|
@ -1458,7 +1457,6 @@ en:
|
|||
qq: QQ Browser
|
||||
safari: Safari
|
||||
uc_browser: UC Browser
|
||||
unknown_browser: Unknown Browser
|
||||
weibo: Weibo
|
||||
current_session: Current session
|
||||
description: "%{browser} on %{platform}"
|
||||
|
@ -1471,10 +1469,9 @@ en:
|
|||
chrome_os: ChromeOS
|
||||
firefox_os: Firefox OS
|
||||
ios: iOS
|
||||
kai_os: KaiOS
|
||||
linux: Linux
|
||||
mac: macOS
|
||||
unknown_platform: Unknown Platform
|
||||
other: unknown platform
|
||||
windows: Windows
|
||||
windows_mobile: Windows Mobile
|
||||
windows_phone: Windows Phone
|
||||
|
|
|
@ -81,10 +81,9 @@ const startMaster = () => {
|
|||
log.warn(`Starting streaming API server master with ${numWorkers} workers`);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {Object.<string, any>}
|
||||
*/
|
||||
const pgConfigFromEnv = () => {
|
||||
const startWorker = async (workerId) => {
|
||||
log.warn(`Starting worker ${workerId}`);
|
||||
|
||||
const pgConfigs = {
|
||||
development: {
|
||||
user: process.env.DB_USER || pg.defaults.user,
|
||||
|
@ -103,45 +102,16 @@ const pgConfigFromEnv = () => {
|
|||
},
|
||||
};
|
||||
|
||||
let baseConfig;
|
||||
|
||||
if (process.env.DATABASE_URL) {
|
||||
baseConfig = dbUrlToConfig(process.env.DATABASE_URL);
|
||||
} else {
|
||||
baseConfig = pgConfigs[env];
|
||||
|
||||
if (process.env.DB_SSLMODE) {
|
||||
switch(process.env.DB_SSLMODE) {
|
||||
case 'disable':
|
||||
case '':
|
||||
baseConfig.ssl = false;
|
||||
break;
|
||||
case 'no-verify':
|
||||
baseConfig.ssl = { rejectUnauthorized: false };
|
||||
break;
|
||||
default:
|
||||
baseConfig.ssl = {};
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...baseConfig,
|
||||
max: process.env.DB_POOL || 10,
|
||||
connectionTimeoutMillis: 15000,
|
||||
application_name: '',
|
||||
};
|
||||
};
|
||||
|
||||
const startWorker = async (workerId) => {
|
||||
log.warn(`Starting worker ${workerId}`);
|
||||
|
||||
const app = express();
|
||||
|
||||
app.set('trust proxy', process.env.TRUSTED_PROXY_IP ? process.env.TRUSTED_PROXY_IP.split(/(?:\s*,\s*|\s+)/) : 'loopback,uniquelocal');
|
||||
|
||||
const pgPool = new pg.Pool(pgConfigFromEnv());
|
||||
const pgPool = new pg.Pool(Object.assign(pgConfigs[env], dbUrlToConfig(process.env.DATABASE_URL), {
|
||||
max: process.env.DB_POOL || 10,
|
||||
connectionTimeoutMillis: 15000,
|
||||
ssl: !!process.env.DB_SSLMODE && process.env.DB_SSLMODE !== 'disable',
|
||||
}));
|
||||
|
||||
const server = http.createServer(app);
|
||||
const redisNamespace = process.env.REDIS_NAMESPACE || null;
|
||||
|
||||
|
|
Loading…
Reference in a new issue