Release v3 (#23)

This commit is contained in:
Nikita Karamov 2023-09-02 22:23:43 +00:00 committed by GitHub
commit 658fc19dcb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
89 changed files with 7261 additions and 3367 deletions

View file

@ -1 +0,0 @@
cover 95%

View file

@ -1,17 +1,27 @@
# This EditorConfig is part of Share₂Fedi
# https://github.com/kytta/share2fedi
#
# SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
# SPDX-License-Identifier: CC0-1.0
root = true root = true
[*] [*]
charset = utf-8 charset = utf-8
end_of_line = lf end_of_line = lf
indent_style = tab indent_style = tab
tab_width = 2
insert_final_newline = true insert_final_newline = true
max_line_length = 80 max_line_length = 80
trim_trailing_whitespace = true trim_trailing_whitespace = true
[*.md] [src/i18n/translations/*.json]
indent_size = 2
indent_style = space
max_line_length = off max_line_length = off
indent_style = space
indent_size = 4
[*.md]
indent_style = space
trim_trailing_whitespace = false trim_trailing_whitespace = false
[*.yml] [*.yml]

View file

@ -1,2 +1,10 @@
# This ESLint ignore file is part of Share₂Fedi
# https://github.com/kytta/share2fedi
#
# SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
# SPDX-License-Identifier: CC0-1.0
.vercel/
/dist/ /dist/
/public/ node_modules/
script/

View file

@ -1,22 +1,29 @@
// This ESLint config is part of ShareFedi
// https://github.com/kytta/share2fedi
//
// SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
// SPDX-License-Identifier: CC0-1.0
{ {
"root": true,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:unicorn/recommended",
"plugin:astro/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"env": { "env": {
"browser": true "browser": true
}, },
"extends": ["eslint:recommended", "plugin:unicorn/recommended", "prettier"],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"overrides": [ "overrides": [
{ {
"files": ["gulpfile.js", "api/*.js"], "files": ["*.astro"],
"env": { "parser": "astro-eslint-parser",
"node": true, "parserOptions": {
"browser": false "parser": "@typescript-eslint/parser",
}, "extraFileExtensions": [".astro"]
"rules": {
"unicorn/prefer-module": 0,
"unicorn/prefer-node-protocol": 0
} }
} }
] ]

5
.github/FUNDING.yml vendored
View file

@ -1,3 +1,8 @@
# This file is part of Share₂Fedi
# https://github.com/kytta/share2fedi
#
# SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
# SPDX-License-Identifier: CC0-1.0
github: kytta github: kytta
liberapay: kytta liberapay: kytta
custom: paypal.me/NickKaramoff custom: paypal.me/NickKaramoff

32
.github/workflows/check.yml vendored Normal file
View file

@ -0,0 +1,32 @@
# This file is part of Share₂Fedi
# https://github.com/kytta/share2fedi
#
# SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
# SPDX-License-Identifier: AGPL-3.0-only
name: Check and build
on:
push:
branches:
- "main"
pull_request:
branches:
- "main"
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Use latest Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- run: pnpm install
- run: pnpm check
- run: pnpm build

31
.github/workflows/deploy-deno.yml vendored Normal file
View file

@ -0,0 +1,31 @@
name: Deploy to Deno
on:
push:
branches:
- "main"
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8
- run: pnpm install --frozen-lockfile
- run: pnpm run build --s2f-use-deno
- name: Upload to Deno Deploy
uses: denoland/deployctl@v1
with:
project: share2fedi
entrypoint: server/entry.mjs
root: dist

312
.gitignore vendored
View file

@ -1,305 +1,19 @@
# This Git ignore file is part of Share₂Fedi
# https://github.com/kytta/share2fedi
#
# SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
# SPDX-License-Identifier: CC0-1.0
# Created by https://www.toptal.com/developers/gitignore/api/node,now,visualstudiocode,webstorm+all,windows,macos,linux # Outputs
# Edit at https://www.toptal.com/developers/gitignore?templates=node,now,visualstudiocode,webstorm+all,windows,macos,linux /dist/
### Linux ### # Cache/state
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/ node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
.env.production
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
### now ###
.now
.vercel
### VisualStudioCode ###
.vscode/*
*.code-workspace
# Local History for Visual Studio Code
.history/
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
### WebStorm+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### WebStorm+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
# Editors/IDEs
.idea/ .idea/
.vscode/
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 # Backend
.vercel/
*.iml .netlify
modules.xml
.idea/misc.xml
*.ipr
# Sonarlint plugin
.idea/sonarlint
### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.toptal.com/developers/gitignore/api/node,now,visualstudiocode,webstorm+all,windows,macos,linux
/public

10
.husky/pre-commit Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env sh
# This file is part of Share₂Fedi
# https://github.com/kytta/share2fedi
#
# SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
# SPDX-License-Identifier: CC0-1.0
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged

1
.node-version Normal file
View file

@ -0,0 +1 @@
18

View file

@ -1,27 +0,0 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: check-json
- id: check-toml
- id: check-yaml
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.0-alpha.9-for-vscode"
hooks:
- id: prettier
additional_dependencies:
- prettier@2
- repo: https://github.com/pre-commit/mirrors-eslint
rev: "v8.43.0"
hooks:
- id: eslint
additional_dependencies:
- eslint
- eslint-config-prettier
- eslint-plugin-unicorn
- prettier@2

View file

@ -1,5 +1,13 @@
*.md # This Prettier ignore file is part of Share₂Fedi
# https://github.com/kytta/share2fedi
#
# SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
# SPDX-License-Identifier: CC0-1.0
.vercel/
/dist/ /dist/
/public/ node_modules/
/.vercel/ script/
pnpm-lock.yaml pnpm-lock.yaml
src/i18n/translations/*.json

View file

@ -1,4 +0,0 @@
{
"quoteProps": "consistent",
"trailingComma": "es5"
}

21
.reuse/dep5 Normal file
View file

@ -0,0 +1,21 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Share₂Fedi
Upstream-Contact: Nikita Karamov <me@kytta.dev>
Source: https://github.com/kytta/share2fedi
Files: public/site.webmanifest
Copyright: 2023 Nikita Karamov <me@kytta.dev>
License: AGPL-3.0-only
Files: src/i18n/translations/*.json
Copyright: 2023 Nikita Karamov <me@kytta.dev>
License: AGPL-3.0-only
Files:
assets/*.png
assets/*.svg
public/*.ico
public/*.png
public/*.svg
Copyright: 2023 Nikita Karamov <me@kytta.dev>
License: CC-BY-4.0

8
.vercelignore Normal file
View file

@ -0,0 +1,8 @@
# This Vercel ignore file is part of Share₂Fedi
# https://github.com/kytta/share2fedi
#
# SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
# SPDX-License-Identifier: CC0-1.0
/assets/
/script/

View file

@ -1,8 +1,79 @@
<!--
This change log is part of Share₂Fedi
https://github.com/kytta/share2fedi
SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
SPDX-License-Identifier: CC0-1.0
-->
# Changelog # Changelog
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v3 (unreleased)][Unreleased]
This version is a huge reinvention of toot. The name was changed to Share₂Fedi,
as to indicate that sharing to other federated networks is now possible.
### ⚠️ BREAKING CHANGES
Share₂Fedi is now an [Astro](https://astro.build/) site. The migration allowed
us to have a performant service that is easily hostable on both serverless
platforms, like Vercel or Netlify, as well as locally. Setting the project up
now takes seconds! This comes with changes, though:
- **static files aren't built any more**, but generated server-side
- **new output directory**: ~~`public/`~~`dist/`
- this also means that `public/` **is not ignored any more**
Some changes came with the name change:
- **changed API endpoint path**: ~~`/api/toot`~~`/`
- just send a POST request instead of a GET request with the same body
### Added
- **new federated social networks**
- Friendica
- GNU Social
- Hubzilla
- Misskey (+ flavours)
- **new ways to host**
- Netlify
- Cloudflare Pages
- **multilingual share page**
- Share₂Fedi can be used in English, German, and Russian.
[Help us with other languages!](./src/i18n/translations.ts)
- remembering of multiple Fediverse instances
- new API endpoints
- `/api/instances` will return the list of popular instances
- `/api/detect/[host]` will detect the Fediverse project used by a host
- a privacy policy describing what data is being processed and stored
- a link to the status page
### Changed
- **new project name**: Share₂Fedi (see
[GH#24](https://github.com/kytta/share2fedi/issues/24))
- new default instance URL: <https://s2f.kytta.dev>
- new logo
- new design
- repository moved back to GitHub
- licence of the project is now AGPL v3 **only**
- for now, this has no effect. If AGPL v4 ever comes out, Share₂Fedi v2 will
not be available under it
- s2f is now being built with Astro
- Share₂Fedi is now 100% server-side rendered. You don't have to host any
static files, all you need is to run the Node server.
- when developing, the API endpoint can now be tested locally
### Removed
- GoatCounter analytics. I will no longer track the visitors of s2f.kytta.dev
## [2.4.5] - 2023-06-17 ## [2.4.5] - 2023-06-17
@ -122,7 +193,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Changed ### Changed
- design of the page so that it looks more like a Mastodon website (without impersonating anyone) - design of the page so that it looks more like a Mastodon website (without
impersonating anyone)
### Fixed ### Fixed
@ -136,7 +208,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Security ### Security
- migrated from `gulp-sass` to `@mr-hope/gulp-sass` to avoid loading and building `node-sass` and other old deps - migrated from `gulp-sass` to `@mr-hope/gulp-sass` to avoid loading and
building `node-sass` and other old deps
## [1.1.1] - 2021-03-03 ## [1.1.1] - 2021-03-03
@ -185,24 +258,25 @@ Initial release of the site
- Add main code for the site - Add main code for the site
[Unreleased]: https://codeberg.org/kytta/toot/compare/v2.4.5...HEAD [Unreleased]: https://github.com/kytta/share2fedi/compare/v2.4.5...HEAD
[2.4.5]: https://codeberg.org/kytta/toot/compare/v2.4.4...v2.4.5 [2.4.5]: https://github.com/kytta/share2fedi/compare/v2.4.4...v2.4.5
[2.4.4]: https://codeberg.org/kytta/toot/compare/v2.4.3...v2.4.4 [2.4.4]: https://github.com/kytta/share2fedi/compare/v2.4.3...v2.4.4
[2.4.3]: https://codeberg.org/kytta/toot/compare/v2.4.2...v2.4.3 [2.4.3]: https://github.com/kytta/share2fedi/compare/v2.4.2...v2.4.3
[2.4.2]: https://codeberg.org/kytta/toot/compare/v2.4.1...v2.4.2 [2.4.2]: https://github.com/kytta/share2fedi/compare/v2.4.1...v2.4.2
[2.4.1]: https://codeberg.org/kytta/toot/compare/v2.4.0...v2.4.1 [2.4.1]: https://github.com/kytta/share2fedi/compare/v2.4.0...v2.4.1
[2.4.0]: https://codeberg.org/kytta/toot/compare/v2.3.1...v2.4.0 [2.4.0]: https://github.com/kytta/share2fedi/compare/v2.3.1...v2.4.0
[2.3.1]: https://codeberg.org/kytta/toot/compare/v2.3.0...v2.3.1 [2.3.1]: https://github.com/kytta/share2fedi/compare/v2.3.0...v2.3.1
[2.3.0]: https://codeberg.org/kytta/toot/compare/v2.2.2...v2.3.0 [2.3.0]: https://github.com/kytta/share2fedi/compare/v2.2.2...v2.3.0
[2.2.2]: https://codeberg.org/kytta/toot/compare/v2.2.1...v2.2.2 [2.2.2]: https://github.com/kytta/share2fedi/compare/v2.2.1...v2.2.2
[2.2.1]: https://codeberg.org/kytta/toot/compare/v2.2.0...v2.2.1 [2.2.1]: https://github.com/kytta/share2fedi/compare/v2.2.0...v2.2.1
[2.2.0]: https://codeberg.org/kytta/toot/compare/v2.1.0...v2.2.0 [2.2.0]: https://github.com/kytta/share2fedi/compare/v2.1.0...v2.2.0
[2.1.0]: https://codeberg.org/kytta/toot/compare/v2.0.0...v2.1.0 [2.1.0]: https://github.com/kytta/share2fedi/compare/v2.0.0...v2.1.0
[2.0.0]: https://codeberg.org/kytta/toot/compare/v1.2.2...v2.0.0 [2.0.0]: https://github.com/kytta/share2fedi/compare/v1.2.2...v2.0.0
[1.2.2]: https://codeberg.org/kytta/toot/compare/v1.2.1...v1.2.2 [1.2.2]: https://github.com/kytta/share2fedi/compare/v1.2.1...v1.2.2
[1.2.1]: https://codeberg.org/kytta/toot/compare/v1.2.0...v1.2.1 [1.2.1]: https://github.com/kytta/share2fedi/compare/v1.2.0...v1.2.1
[1.2.0]: https://codeberg.org/kytta/toot/compare/v1.1.2...v1.2.0 [1.2.0]: https://github.com/kytta/share2fedi/compare/v1.1.2...v1.2.0
[1.1.2]: https://codeberg.org/kytta/toot/compare/v1.1.1...v1.1.2 [1.1.2]: https://github.com/kytta/share2fedi/compare/v1.1.1...v1.1.2
[1.1.1]: https://codeberg.org/kytta/toot/compare/v1.1.0...v1.1.1 [1.1.1]: https://github.com/kytta/share2fedi/compare/v1.1.0...v1.1.1
[1.1.0]: https://codeberg.org/kytta/toot/compare/v1.0.0...v1.1.0 [1.1.0]: https://github.com/kytta/share2fedi/compare/v1.0.0...v1.1.0
[1.0.0]: https://codeberg.org/kytta/toot/compare/e85aa15400bcdbcccf655d331f72df8304744b85...v1.0.0 [1.0.0]:
https://github.com/kytta/share2fedi/compare/e85aa15400bcdbcccf655d331f72df8304744b85...v1.0.0

118
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,118 @@
<!--
This file is part of Share₂Fedi
https://github.com/kytta/share2fedi
SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
SPDX-License-Identifier: CC0-1.0
-->
# Contributing guide
First off, thank you for considering contributing to Share₂Fedi! There are many
ways you can improve on the project:
- [write new and improve on the old code](#improving-code)
- [write documentation](#writing-documentation)
- [translate UI strings](#translating)
- [report bugs](#reporting-bugs)
Please, follow this guide if you want to contribute. We promise, it's not too
many rules! Following this helps us merge changes quicker!
Unsure where to begin contributing? You can start by looking through
[the help-wanted issues](https://github.com/kytta/share2fedi/labels/help%20wanted)!
## Improving code
Before you start, make sure you've got a fresh Node.js version (v18 should work)
installed. You'll also need to [install pnpm](https://pnpm.io/installation), as
this is our package manager of choice.
1. Fork the repository and clone it
2. Install dependencies:
```sh
pnpm install
```
3. To start a dev server, run:
```sh
pnpm dev
```
This server will auto-update on changes to the file
4. After implementing a feature, create a new Git branch and commit your changes
on it
5. Push the branch and open a PR.
### Adding support for other Fediverse projects
In order for a Fediverse project to be supported, it has to have a "Share" page
located at a fixed address. That means, that the address is the same for all
users and all frontends. For example, Mastodon's "Share" page is always at
`/share`. The share page should also accept the text of the post via URL
parameters. For example, Mastodon allows pre-filling the text of a post using
`?text=`. Lastly, it should be listed on
[fediverse.observer](https://fediverse.observer/).
If the Fediverse project satisfies these requirements, you can add it to
Share2Fedi. For this:
1. Add an entry to `supportedProjects` inside `src/lib/project.ts`.
- keep the list in alphabetical order
- the key should match the software name from NodeInfo/fediverse.observer
- the value should be an object of type `ProjectPublishConfig`. The endpoint
is the path to the "Share" page (leading slash optional).
- if the service you're adding is a flavour of an already supported service,
use the variable to reduce code duplication. See `mastodonConfig` for an
example
2. Pick an instance of the project you've added and visit
`/api/detect/<INSTANCE-DOMAIN>`. Make sure the detection is correct
3. Go to the `/` and try to share something to the instance. Make sure the
"Share" page opens with correct parameters.
## Writing documentation
Share₂Fedi's documentation is pretty complete at the moment, but you are free to
fix errors and to add clarifications. The only documentation we have is the
`README.md` and `CONTRIBUTING.md` that you're reading right now.
## Translating
Starting with v3, Share₂Fedi has a very primitive translation framework built
in. Despite it being simple, you can edit translations and add new languages in
form of JSON-based dictionaries.
There are two ways you can add/edit translations:
1. The JSON files under `src/i18n/translations` represent dictionaried for
different languages. The two-letter codes correspond to the ISO 639-1
language codes.
- to edit translations, just edit the files. Refer to
[the coding guide](#improving-code) for more information on how to do this.
2. [Weblate](https://translate.codeberg.org/engage/share2fedi/), a web-based
tool that simplifies this process.
- we use Codeberg's Weblate instance, which requires a Codeberg account. If
you have one, this is the easiest way to edit translations.
## Reporting bugs
> [!IMPORTANT]
> If you find a security vulnerability, do NOT open an issue. Email
> [Nikita Karamov](mailto:me@kytta.dev) instead.
If you find a bug you can't (or don't want to) fix yourself, don't hesitate
filing an issue. We do not have a preset issue template, but try to answer these
questions in the issue body:
1. What version of Share₂Fedi are you using?
2. How do you deploy it (Node/Vercel/Netlify/Cloudflare/Deno)?
3. What did you do?
4. What did you expect to see?
5. What did you see instead?
---
We are looking forward to your contributions!

235
LICENSES/AGPL-3.0-only.txt Normal file
View file

@ -0,0 +1,235 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based on the Program.
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
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 <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>.

156
LICENSES/CC-BY-4.0.txt Normal file
View file

@ -0,0 +1,156 @@
Creative Commons Attribution 4.0 International
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors.
Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensors permission is not necessary for any reasonfor example, because of any applicable exception or limitation to copyrightthen that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public.
Creative Commons Attribution 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
Section 1 Definitions.
a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
h. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
Section 2 Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
A. reproduce and Share the Licensed Material, in whole or in part; and
B. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
3. Term. The term of this Public License is specified in Section 6(a).
4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
5. Downstream recipients.
A. Offer from the Licensor Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this Public License.
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
Section 3 License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified form), You must:
A. retain the following if it is supplied by the Licensor with the Licensed Material:
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of warranties;
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License.
Section 4 Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
Section 5 Disclaimer of Warranties and Limitation of Liability.
a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
Section 6 Term and Termination.
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
2. upon express reinstatement by the Licensor.
c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
Section 7 Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
Section 8 Interpretation.
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
Creative Commons may be contacted at creativecommons.org.

121
LICENSES/CC0-1.0.txt Normal file
View file

@ -0,0 +1,121 @@
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.

8
LICENSES/ISC.txt Normal file
View file

@ -0,0 +1,8 @@
ISC License:
Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
Copyright (c) 1995-2003 by Internet Software Consortium
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

149
README.md
View file

@ -1,108 +1,157 @@
<h1 align="center"><img src="assets/logo.svg" width="128" height="128" alt="toot"></h1> <!--
This README is part of Share₂Fedi
https://github.com/kytta/share2fedi
> Cross-instance share page for Mastodon SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
SPDX-License-Identifier: CC0-1.0
-->
[toot] allows you to share stuff on Mastodon, cross-instance. Just put in your <h1 align="center"><img src="assets/share2fedi.svg" width="520" height="160" alt="Share2Fedi"></h1>
post text and the instance URL and click Toot!
And if you open this page with `text` URL parameter, it will be auto-inserted > Instance-agnostic share page for the Fediverse.
in the text field. The same goes for the `instance` URL parameter. This can be
used to build custom share buttons for Mastodon: **[Share₂Fedi]** (pronounced share-to-fedi) allows you to share stuff on
Mastodon, Misskey, Friendica, and other federated social networks,
instance-agnostic. Just type in the post text and the instance URL, and click
Post!
Or, open this page with the prefilled `text` URL parameter—it will be
automatically inserted into the text field. The same goes for the `instance` and
`lang` URL parameters. This can be used to build custom share buttons for the
federated social networks:
```html ```html
<a href="https://toot.kytta.dev/?text=Hello%20world!&instance=https%3A%2F%2Fmastodon.xyz"> <a href="https://s2f.kytta.dev/?text=Hello%20world!&instance=mastodon.xyz">
Share on Mastodon Share on mastodon.xyz
</a> </a>
``` ```
The instance URL can be saved in your `localStorage` to be automatically The instance URL can be saved in your `localStorage` to be automatically
appended later — handy! appended if used later—handy!
> [!IMPORTANT]
> I know I provide [a Share₂Fedi instance](https://s2f.kytta.dev) for others to
> use, but if you want to use Share₂Fedi for your share buttons, **please
> consider self-hosting it**. Although it's free now, running my instance may
> become too expensive for me in the future.
## Hosting ## Hosting
### One-click Vercel deploy ### Vercel, Netlify, Cloudflare Pages
For now, toot is a tad bit vendor-locked to run on Share₂Fedi was designed to run on [Vercel](https://vercel.com/), but you can
[Vercel](https://vercel.com/). To deploy it yourself, you can use the following also run it on [Netlify](https://www.netlify.com/) or
button: [Cloudflare Pages](https://pages.cloudflare.com/). To deploy it yourself (it's
free!), you can use the following buttons:
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fkytta%2Ftoot) [![Deploy to Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fkytta%2Fshare2fedi)
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/kytta/share2fedi)
To deploy to Cloudflare Pages, fork the repository and
[follow the instructions](https://docs.astro.build/en/guides/deploy/cloudflare/#how-to-deploy-a-site-with-git).
### Host it yourself ### Host it yourself
Self-hosting toot outside of Vercel requires some extra setup: Self-hosting Share₂Fedi outside of SSR providers requires some extra setup:
1. Make sure you have got Node.js v12 or later as well as pnpm installed **Prerequisites:** modern Node.js (v18 is recommended), `pnpm`. You can host
with Deno, but Node.js is still required to build Share₂Fedi.
2. Build the static part of toot: 1. Install dependencies.
```sh ```sh
pnpm install # to install dependencies pnpm install
pnpm run build # to build the website
``` ```
3. Run the backend server for the form: 2. Build.
```sh ```sh
node api/toot.js pnpm build
``` ```
or if you want to run the process in the background: If you want to use Deno, add the `--s2f-use-deno` flag:
```sh ```sh
pm2 start api/toot.js --watch --ignore-watch="node_modules" pnpm build --s2f-use-deno
``` ```
> You can find a summary for pm2 at: https://pm2.keymetrics.io/docs/usage/quick-start/ 3. Run server.
4. Set up webserver > By default, this will only listen on localhost port 3000. To enable
> listening on a certain host and/or port, set the `HOST` and `PORT`
> environment variables, respectively.
```sh
node dist/server/entry.mjs
```
In production, you might want to use a process manager, like
[PM2](https://pm2.keymetrics.io/docs/usage/quick-start/):
```sh
# Start the app, restart on file changes (except node_modules)
pm2 start dist/server/entry.mjs --name "Share2Fedi" --watch --ignore-watch="node_modules"
```
> More information about self-hosting an Astro website with Node:
> https://docs.astro.build/en/guides/integrations-guide/node/#standalone
If you've built Share₂Fedi for Deno:
```sh
deno run --allow-net --allow-read --allow-env ./dist/server/entry.mjs
```
> More information about self-hosting an Astro website with Deno:
> https://docs.astro.build/en/guides/integrations-guide/deno/#usage
4. Set up a reverse proxy.
Basically, you need to run a reverse proxy that would redirect all incoming
requests to `localhost:3000`. Here's how to achieve this in various HTTP
servers:
1. Apache 1. Apache
```apacheconf ```apacheconf
DocumentRoot "path_to_toot/public" ProxyPass "/" "http://localhost:3000/"
ProxyPass "/api/toot" "http://localhost:8000/"
``` ```
2. Nginx 2. Nginx
```nginxconf ```nginxconf
root path_to_toot/public; location / {
index.html; proxy_pass http://localhost:3000/;
location /api/toot {
proxy_pass http://localhost:8000/;
} }
``` ```
3. Caddy 3. Caddy
```caddy ```caddy
root * path_to_toot/public; reverse_proxy :3000
try_files index.html
handle_path /api/toot {
reverse_proxy localhost:8000
}
``` ```
### Docker
If you _really_ have to use Docker, there is
[a good guide on building Astro apps with Docker](https://docs.astro.build/en/recipes/docker/).
**I will not** provide support for Docker-based deployments in the observable
future.
## See also ## See also
**[📯 Shareon](https://shareon.js.org)** **[📯 Shareon](https://shareon.js.org)** (lightweight, stylish, and ethical
(lightweight, stylish, and ethical share buttons) uses [toot] under the hood! share buttons) uses **Share₂Fedi** under the hood!
## Licence ## Licence
Copyright © 20202022 [Nikita Karamov](https://www.kytta.dev/) © 20202023 [Nikita Karamov]\
Licenced under the [GNU Affero General Public License, version 3](https://spdx.org/licenses/AGPL-3.0-only.html) Licensed under the [GNU Affero General Public License v3.0 only][AGPL-3.0-only].
The toot logo is based on Mastodons Simple logo, licensed under [AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.html).
The repo banner includes Mastodons Full logo, licensed under [AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.html).
--- ---
This project is hosted on Codeberg: <https://codeberg.org/kytta/toot> This project is hosted on GitHub: <https://github.com/kytta/share2fedi.git>
[toot]: https://toot.kytta.dev/ [AGPL-3.0-only]: https://spdx.org/licenses/AGPL-3.0-only.html
[Nikita Karamov]: https://www.kytta.dev
[Share₂Fedi]: https://s2f.kytta.dev/

View file

@ -1,39 +0,0 @@
/*!
toot - Cross-instance share page for Mastodon
Copyright (C) 2020-2022 Nikita Karamov <me@kytta.dev>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
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/>.
*/
const http = require("http");
http
.createServer(async (request, response) => {
const buffers = [];
for await (const chunk of request) {
buffers.push(chunk);
}
const data = Buffer.concat(buffers).toString();
const searchParameters = new URLSearchParams(data);
const text = searchParameters.get("text") || "";
const instanceURL =
searchParameters.get("instance") || "https://mastodon.social/";
const finalURL = new URL("share", instanceURL);
finalURL.search = new URLSearchParams({ text }).toString();
response.writeHead(303, { Location: finalURL.toString() }).end();
})
.listen(8000);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 45 KiB

View file

@ -1,9 +0,0 @@
<svg viewBox="0 0 174 186" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2">
<path d="M169.446 111.27c-2.545 13.093-22.794 27.422-46.05 30.199-12.127 1.447-24.067 2.777-36.799 2.193-20.822-.954-37.252-4.97-37.252-4.97 0 2.027.125 3.957.375 5.762 2.707 20.549 20.376 21.78 37.113 22.354 16.893.578 31.935-4.165 31.935-4.165l.694 15.272s-11.816 6.345-32.865 7.512c-11.607.638-26.019-.292-42.805-4.735C7.386 171.056 1.125 132.249.167 92.873-.125 81.182.055 70.158.055 60.938c0-40.264 26.381-52.066 26.381-52.066C39.738 2.763 62.563.194 86.292 0h.583c23.729.194 46.569 2.763 59.87 8.872 0 0 26.38 11.802 26.38 52.066 0 0 .331 29.707-3.679 50.332" fill="#3088d4" fill-rule="nonzero"/>
<g fill="#fff">
<path d="M170.804 102.751c-1.682.442-3.452.639-5.298.639-5.619 0-9.961-1.469-13.025-4.406-3.065-2.938-4.598-7.216-4.598-12.835V61.534h-8.428v-9.578h8.428V40.271h11.973v11.685h12.748c.357 2.821.521 5.813.521 8.982l-.001.596h-13.268v24.328c0 2.49.606 4.39 1.819 5.699 1.214 1.309 2.969 1.963 5.268 1.963 1.869 0 3.52-.341 4.944-1.046l-.175 2.226-.908 8.047z"/>
<path d="M115.127 103.39c-5.172 0-9.834-1.118-13.984-3.353-4.151-2.235-7.391-5.347-9.722-9.338-2.33-3.991-3.496-8.509-3.496-13.553 0-5.044 1.166-9.546 3.496-13.505 2.331-3.959 5.571-7.056 9.722-9.29 4.15-2.235 8.812-3.353 13.984-3.353 5.236 0 9.929 1.118 14.079 3.353 4.151 2.234 7.391 5.331 9.722 9.29 2.33 3.959 3.496 8.461 3.496 13.505 0 5.044-1.166 9.562-3.496 13.553-2.331 3.991-5.571 7.103-9.722 9.338-4.15 2.235-8.843 3.353-14.079 3.353zm0-10.249c4.405 0 8.045-1.468 10.918-4.406 2.874-2.937 4.311-6.8 4.311-11.589 0-4.789-1.437-8.652-4.311-11.589-2.873-2.937-6.513-4.406-10.918-4.406-4.406 0-8.03 1.469-10.871 4.406-2.842 2.937-4.262 6.8-4.262 11.589 0 4.789 1.42 8.652 4.262 11.589 2.841 2.938 6.465 4.406 10.871 4.406z" fill-rule="nonzero"/>
<path d="M61.011 103.39c-5.172 0-9.833-1.118-13.983-3.353-4.151-2.235-7.391-5.347-9.722-9.338-2.331-3.991-3.496-8.509-3.496-13.553 0-5.044 1.165-9.546 3.496-13.505 2.331-3.959 5.571-7.056 9.722-9.29 4.15-2.235 8.811-3.353 13.983-3.353 5.236 0 9.929 1.118 14.08 3.353 4.15 2.234 7.391 5.331 9.722 9.29 2.33 3.959 3.495 8.461 3.495 13.505 0 5.044-1.165 9.562-3.495 13.553-2.331 3.991-5.572 7.103-9.722 9.338-4.151 2.235-8.844 3.353-14.08 3.353zm0-10.249c4.406 0 8.046-1.468 10.919-4.406 2.874-2.937 4.31-6.8 4.31-11.589 0-4.789-1.436-8.652-4.31-11.589-2.873-2.937-6.513-4.406-10.919-4.406-4.405 0-8.029 1.469-10.871 4.406-2.841 2.937-4.262 6.8-4.262 11.589 0 4.789 1.421 8.652 4.262 11.589 2.842 2.938 6.466 4.406 10.871 4.406z" fill-rule="nonzero"/>
<path d="M.575 51.956h7.854V40.271h11.972v11.685h13.696v9.578H20.401v24.328c0 2.49.607 4.39 1.82 5.699 1.213 1.309 2.969 1.963 5.268 1.963 2.681 0 4.916-.702 6.704-2.107l3.352 8.524c-1.404 1.15-3.112 2.012-5.124 2.587-2.011.574-4.134.862-6.369.862-5.619 0-9.961-1.469-13.026-4.406-3.065-2.938-4.597-7.216-4.597-12.835V61.534H.053l.002-.596c0-3.169.163-6.161.52-8.982z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3 KiB

26
assets/pentagon.svg Normal file
View file

@ -0,0 +1,26 @@
<!-- © 2022 Nikita Karamov. Licensed under CC-BY 4.0 -->
<svg viewBox="0 0 64 64" width="512" height="512" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<defs>
<filter id="blur">
<feGaussianBlur stdDeviation="15"></feGaussianBlur>
</filter>
<clipPath id="pentagon">
<path d="m38.802 1.632 23.656 29.212-20.473 31.524-36.307-9.729-1.968-37.537z"></path>
</clipPath>
</defs>
<g clip-path="url(#pentagon)">
<g filter="url(#blur)">
<circle cx="0" cy="10" fill="#F44336" r="39"></circle>
<circle cx="45" cy="-5" fill="#FFEB3B" r="39"></circle>
<circle cx="70" cy="25" fill="#4CAF50" r="39"></circle>
<circle cx="50" cy="65" fill="#03A9F4" r="39"></circle>
<circle cx="5" cy="70" fill="#673AB7" r="39"></circle>
<circle cx="50" cy="31.5" fill="#4CAF50" r="12"></circle>
<circle cx="37.5" cy="50.5" fill="#03A9F4" r="12"></circle>
<circle cx="15.5" cy="44.5" fill="#673AB7" r="12"></circle>
<circle cx="14" cy="22" fill="#F44336" r="12"></circle>
<circle cx="36" cy="14" fill="#FFEB3B" r="12"></circle>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

29
assets/s2f.svg Normal file
View file

@ -0,0 +1,29 @@
<!-- © 2022 Nikita Karamov. Licensed under CC-BY 4.0 -->
<svg viewBox="0 0 64 64" width="512" height="512" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<defs>
<filter id="blur">
<feGaussianBlur stdDeviation="15"></feGaussianBlur>
</filter>
<clipPath id="pentagon">
<path d="m38.802 1.632 23.656 29.212-20.473 31.524-36.307-9.729-1.968-37.537z"></path>
</clipPath>
</defs>
<g clip-path="url(#pentagon)">
<g filter="url(#blur)">
<circle cx="0" cy="10" fill="#F44336" r="39"></circle>
<circle cx="45" cy="-5" fill="#FFEB3B" r="39"></circle>
<circle cx="70" cy="25" fill="#4CAF50" r="39"></circle>
<circle cx="50" cy="65" fill="#03A9F4" r="39"></circle>
<circle cx="5" cy="70" fill="#673AB7" r="39"></circle>
<circle cx="50" cy="31.5" fill="#4CAF50" r="12"></circle>
<circle cx="37.5" cy="50.5" fill="#03A9F4" r="12"></circle>
<circle cx="15.5" cy="44.5" fill="#673AB7" r="12"></circle>
<circle cx="14" cy="22" fill="#F44336" r="12"></circle>
<circle cx="36" cy="14" fill="#FFEB3B" r="12"></circle>
</g>
</g>
<path
d="m17.498 27.02h6.489c-.034-4.909-3.81-8.136-9.853-8.136-5.94 0-10.128 3.193-10.093 7.93 0 3.914 2.677 6.077 7.106 7.038l2.506.515c2.781.618 3.708 1.305 3.742 2.472-.034 1.202-1.133 2.094-3.33 2.094-2.575 0-4.12-1.236-4.223-3.536h-6.454c.035 6.283 4.292 9.098 10.78 9.098 6.351 0 10.128-2.747 10.162-7.656-.034-3.81-2.3-6.488-7.793-7.656l-2.06-.446c-2.369-.515-3.433-1.202-3.364-2.403 0-1.099.927-1.888 3.02-1.888 2.198 0 3.228.96 3.365 2.574zm8.761 28.598h11.188v-3.162h-5.704v-.08l1.38-1.141c3.303-2.762 4.164-4.203 4.164-5.885 0-2.702-2.222-4.483-5.724-4.483-3.383 0-5.584 1.881-5.584 4.944h3.762c-.02-1.221.74-1.902 1.822-1.902 1.1 0 1.861.68 1.861 1.782 0 1.04-.66 1.7-1.721 2.602l-5.444 4.483zm13.589-11.432h6.763v-9.75h9.715v-5.459h-9.715v-4.291h10.78v-5.459h-17.543z"
fill="white" />
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

43
assets/share2fedi.svg Normal file
View file

@ -0,0 +1,43 @@
<!-- © 2022 Nikita Karamov. Licensed under CC-BY 4.0 -->
<svg viewBox="0 0 260 80" width="520" height="160" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<defs>
<filter id="blur">
<feGaussianBlur stdDeviation="15"></feGaussianBlur>
</filter>
<clipPath id="pentagon">
<path d="m38.802 1.632 23.656 29.212-20.473 31.524-36.307-9.729-1.968-37.537z"></path>
</clipPath>
</defs>
<g clip-path="url(#pentagon)" transform="scale(0.6) translate(215,60)">
<g filter="url(#blur)">
<circle cx="0" cy="10" fill="#F44336" r="39"></circle>
<circle cx="45" cy="-5" fill="#FFEB3B" r="39"></circle>
<circle cx="70" cy="25" fill="#4CAF50" r="39"></circle>
<circle cx="50" cy="65" fill="#03A9F4" r="39"></circle>
<circle cx="5" cy="70" fill="#673AB7" r="39"></circle>
<circle cx="50" cy="31.5" fill="#4CAF50" r="12"></circle>
<circle cx="37.5" cy="50.5" fill="#03A9F4" r="12"></circle>
<circle cx="15.5" cy="44.5" fill="#673AB7" r="12"></circle>
<circle cx="14" cy="22" fill="#F44336" r="12"></circle>
<circle cx="36" cy="14" fill="#FFEB3B" r="12"></circle>
</g>
</g>
<style>
@media (prefers-color-scheme: dark) {
#text {
fill: #fff
}
}
</style>
<g id="text" fill="#000">
<path
d="M29.39 27.758h8.387C37.732 21.412 32.85 17.24 25.04 17.24c-7.678 0-13.092 4.127-13.047 10.251 0 5.06 3.461 7.855 9.186 9.098l3.24.665c3.594.8 4.792 1.687 4.836 3.196-.044 1.553-1.464 2.707-4.304 2.707-3.328 0-5.325-1.598-5.458-4.571H11.15c.044 8.12 5.547 11.76 13.934 11.76 8.21 0 13.091-3.55 13.136-9.896-.045-4.926-2.974-8.388-10.074-9.897l-2.663-.576c-3.062-.666-4.437-1.554-4.349-3.107 0-1.42 1.199-2.44 3.906-2.44 2.84 0 4.171 1.242 4.349 3.328zm21.002 8.564c0-2.396 1.375-3.816 3.505-3.816 2.22 0 3.506 1.42 3.462 3.816v13.624h8.698V34.503c.044-5.28-3.329-9.097-8.432-9.097-3.594 0-6.213 1.864-7.322 4.926h-.222V17.684h-8.387v32.262h8.698zm26.723 14.024c3.15 0 5.503-1.11 6.967-3.817h.222v3.417h8.121V33.35c0-4.438-4.26-7.943-11.183-7.943-7.233 0-10.783 3.816-11.094 8.21h8.032c.178-1.51 1.287-2.22 2.973-2.22 1.51 0 2.574.71 2.574 1.953v.089c0 1.376-1.553 1.82-5.636 2.13-4.97.355-8.875 2.396-8.875 7.677 0 4.837 3.24 7.1 7.9 7.1zm2.84-5.503c-1.509 0-2.53-.71-2.53-2.086 0-1.242.888-2.219 2.885-2.53 1.376-.221 2.574-.488 3.462-.887v2.041c0 2.22-1.864 3.462-3.817 3.462zm16.641 5.103h8.698V37.343c0-2.796 1.908-4.615 4.482-4.615.888 0 2.308.133 3.195.444V25.76a7.486 7.486 0 0 0-2.219-.355c-2.574 0-4.57 1.553-5.458 4.926h-.266V25.76h-8.432v24.185zm29.417.444c6.7 0 11.05-3.195 11.849-8.254h-7.944c-.488 1.376-1.952 2.13-3.728 2.13-2.573 0-4.082-1.686-4.082-4.038v-.355h15.754V37.83c0-7.677-4.704-12.425-12.027-12.425-7.5 0-12.292 5.014-12.292 12.514 0 7.81 4.704 12.47 12.47 12.47zm-3.905-15.31c.044-2.086 1.775-3.55 3.905-3.55 2.174 0 3.816 1.464 3.86 3.55z" />
<path
d="M158.001 49.946h8.743V37.343h12.558v-7.056h-12.558V24.74h13.934v-7.056h-22.677v32.262zm35.859.444c6.7 0 11.05-3.195 11.848-8.254h-7.944c-.488 1.376-1.952 2.13-3.727 2.13-2.574 0-4.083-1.686-4.083-4.038v-.355h15.754V37.83c0-7.677-4.704-12.425-12.026-12.425-7.5 0-12.293 5.014-12.293 12.514 0 7.81 4.704 12.47 12.47 12.47zm-3.906-15.31c.044-2.086 1.775-3.55 3.905-3.55 2.175 0 3.817 1.464 3.861 3.55zm28.042 15.177c3.417 0 5.725-1.82 6.746-4.26h.177v3.95h8.654V17.683h-8.698v12.293h-.133c-.932-2.486-3.196-4.571-6.79-4.571-4.793 0-9.452 3.683-9.452 12.425 0 8.388 4.349 12.426 9.496 12.426zm3.24-6.657c-2.397 0-3.817-2.174-3.817-5.769s1.42-5.724 3.817-5.724 3.816 2.13 3.816 5.724c0 3.55-1.42 5.77-3.816 5.77zm16.638 6.346h8.698V25.761h-8.698zm4.349-26.715c2.352 0 4.26-1.775 4.26-3.994 0-2.174-1.908-3.95-4.26-3.95-2.397 0-4.305 1.776-4.305 3.95 0 2.22 1.908 3.994 4.305 3.994z" />
</g>
<path fill="#fff"
d="M140.44 64.724h14.463v-4.088h-7.374v-.104l1.785-1.475c4.27-3.57 5.382-5.433 5.382-7.606 0-3.493-2.872-5.795-7.4-5.795-4.372 0-7.218 2.432-7.218 6.39h4.864c-.026-1.578.957-2.458 2.354-2.458 1.423 0 2.406.88 2.406 2.303 0 1.345-.853 2.199-2.225 3.363l-7.037 5.796v3.674z" />
</svg>

After

Width:  |  Height:  |  Size: 4 KiB

60
astro.config.ts Normal file
View file

@ -0,0 +1,60 @@
/* eslint-env node */
/*!
* This file is part of ShareFedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { defineConfig } from "astro/config";
import lightningcss from "vite-plugin-lightningcss";
import cloudflare from "@astrojs/cloudflare";
import deno from "@astrojs/deno";
import netlify from "@astrojs/netlify/functions";
import node from "@astrojs/node";
import vercel from "@astrojs/vercel/serverless";
let adapterConfig = {};
if (process.env.VERCEL) {
console.info("Using Vercel (serverless) adapter...");
adapterConfig = {
adapter: vercel({
functionPerRoute: true,
}),
};
} else if (process.env.CF_PAGES) {
console.info("Using Cloudflare adapter...");
adapterConfig = {
adapter: cloudflare(),
};
} else if (process.env.NETLIFY) {
console.info("Using Netlify (Functions) adapter...");
adapterConfig = {
adapter: netlify(),
};
} else if (process.argv.includes("--s2f-use-deno")) {
console.info("Using Deno adapter...");
adapterConfig = {
adapter: deno(),
};
} else {
console.info("Using Node.js adapter...");
console.info("Run with '--s2f-use-deno' flag to use Deno");
adapterConfig = {
adapter: node({
mode: "standalone",
}),
};
}
export default defineConfig({
site: "https://s2f.kytta.dev",
output: "server",
...adapterConfig,
vite: {
plugins: [lightningcss()],
},
});

View file

@ -1,49 +0,0 @@
const path = require("path");
const gulp = require("gulp");
const postcss = require("gulp-postcss");
const sass = require("gulp-sass")(require("sass"));
const sourcemaps = require("gulp-sourcemaps");
const terser = require("gulp-terser");
const SOURCE_DIR = path.resolve(__dirname, "src");
const OUTPUT_DIR = path.resolve(__dirname, "public");
function html() {
return gulp
.src(path.join(SOURCE_DIR, "index.html"))
.pipe(gulp.dest(OUTPUT_DIR));
}
function css() {
return gulp
.src(path.join(SOURCE_DIR, "scss", "*.scss"))
.pipe(sourcemaps.init())
.pipe(sass.sync().on("error", sass.logError))
.pipe(postcss([require("autoprefixer"), require("postcss-csso")]))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(OUTPUT_DIR));
}
function js() {
return gulp
.src([path.join(SOURCE_DIR, "main.js"), path.join(SOURCE_DIR, "count.js")])
.pipe(sourcemaps.init())
.pipe(terser({ ecma: 5 }))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(OUTPUT_DIR));
}
function staticFiles() {
return gulp
.src(path.join(SOURCE_DIR, "static", "**", "*"))
.pipe(gulp.dest(OUTPUT_DIR));
}
exports.default = gulp.parallel(html, css, js, staticFiles);
exports.watch = () => {
gulp.watch(path.join(SOURCE_DIR, "index.html"), html);
gulp.watch(path.join(SOURCE_DIR, "scss", "*.scss"), css);
gulp.watch(path.join(SOURCE_DIR, "*.js"), js);
gulp.watch(path.join(SOURCE_DIR, "static", "**", "*"), staticFiles);
};

6
netlify.toml Normal file
View file

@ -0,0 +1,6 @@
[build]
command = "pnpm run build"
publish = "dist"
[dev]
command = "pnpm dev"
targetPort = 4321

View file

@ -1,38 +1,78 @@
{ {
"name": "toot", "name": "share2fedi",
"version": "2.4.5", "version": "2.4.5",
"description": "Cross-instance share page for Mastodon", "description": "Instance-agnostic share page for the Fediverse.",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-only",
"author": "Nikita Karamov <me@kytta.dev>", "author": "Nikita Karamov <me@kytta.dev>",
"homepage": "https://toot.kytta.dev/", "homepage": "https://s2f.kytta.dev/",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://codeberg.org/kytta/toot.git" "url": "https://github.com/kytta/share2fedi.git"
}, },
"private": true, "private": true,
"type": "module",
"scripts": { "scripts": {
"build": "gulp", "dev": "astro dev",
"dev": "gulp watch", "start": "astro dev",
"fmt": "prettier --write .", "build": "astro build",
"lint": "prettier --check . && eslint .", "build:icons": "bash ./script/build-icons",
"test": "pnpm run lint", "preview": "astro preview",
"serve": "sirv ./public --dev" "check": "pnpm run /^check:/",
"check:astro": "astro check",
"check:eslint": "eslint .",
"check:prettier": "prettier --check --plugin=prettier-plugin-astro .",
"check:stylelint": "stylelint **/*.scss",
"check:typescript": "tsc --noEmit",
"fix": "pnpm fix:prettier . && pnpm fix:eslint .",
"fix:eslint": "eslint --fix",
"fix:prettier": "prettier --write --ignore-unknown --plugin=prettier-plugin-astro",
"fix:stylelint": "stylelint --fix",
"test": "pnpm run check",
"prepare": "husky install"
},
"browserslist": "cover 95%, last 2 versions, Firefox ESR, not dead",
"dependencies": {
"@astrojs/cloudflare": "^7.0.1",
"@astrojs/deno": "^5.0.0",
"@astrojs/netlify": "^3.0.1",
"@astrojs/node": "^6.0.0",
"@astrojs/vercel": "^4.0.3",
"@nanostores/persistent": "^0.9.1",
"astro": "^3.0.7",
"nanostores": "^0.9.3"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^10.4.2", "@astrojs/check": "^0.2.0",
"browserslist": "^4.19.1", "@types/node": "^18.17.14",
"eslint": "^8.35.0", "@typescript-eslint/eslint-plugin": "^6.5.0",
"eslint-config-prettier": "^8.6.0", "@typescript-eslint/parser": "^6.5.0",
"eslint-plugin-unicorn": "^45.0.2", "eslint": "^8.48.0",
"gulp": "^4.0.2", "eslint-config-prettier": "^9.0.0",
"gulp-postcss": "^9.0.1", "eslint-plugin-astro": "^0.29.0",
"gulp-sass": "^5.1.0", "eslint-plugin-unicorn": "^48.0.1",
"gulp-sourcemaps": "^3.0.0", "husky": "^8.0.0",
"gulp-terser": "^2.1.0", "lint-staged": "^14.0.1",
"postcss": "^8.4.6", "prettier": "^3.0.3",
"postcss-csso": "^6.0.0", "prettier-plugin-astro": "^0.12.0",
"prettier": "^2.8.4", "sass": "^1.66.1",
"sass": "^1.49.7", "sharp": "^0.32.5",
"sirv-cli": "^2.0.2" "stylelint": "^15.10.3",
"stylelint-config-standard-scss": "^10.0.0",
"svgo": "^3.0.2",
"typescript": "^5.2.2",
"vite-plugin-lightningcss": "^0.0.5"
},
"lint-staged": {
"*": "pnpm run fix:prettier",
"*.{astro,js,ts}": "pnpm run fix:eslint",
"*.scss": "pnpm run fix:stylelint",
"assets/*.{png,svg}": "pnpm run build:icons"
},
"prettier": {
"proseWrap": "always",
"singleAttributePerLine": true
},
"stylelint": {
"extends": "stylelint-config-standard-scss"
} }
} }

5
package.json.license Normal file
View file

@ -0,0 +1,5 @@
This file is part of Share₂Fedi
https://github.com/kytta/share2fedi
SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
SPDX-License-Identifier: CC0-1.0

File diff suppressed because it is too large Load diff

5
pnpm-lock.yaml.license Normal file
View file

@ -0,0 +1,5 @@
This (auto-generated) file is part of Share₂Fedi
https://github.com/kytta/share2fedi
SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
SPDX-License-Identifier: CC0-1.0

BIN
public/apple-touch-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
public/banner.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
public/icon-192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

BIN
public/icon-512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

1
public/icon.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 64 64"><defs><clipPath id="a"><path d="m38.802 1.632 23.656 29.212-20.473 31.524-36.307-9.729L3.71 15.102z"/></clipPath><filter id="b"><feGaussianBlur stdDeviation="15"/></filter></defs><g clip-path="url(#a)" filter="url(#b)"><circle cy="10" r="39" fill="#F44336"/><circle cx="45" cy="-5" r="39" fill="#FFEB3B"/><circle cx="70" cy="25" r="39" fill="#4CAF50"/><circle cx="50" cy="65" r="39" fill="#03A9F4"/><circle cx="5" cy="70" r="39" fill="#673AB7"/><circle cx="50" cy="31.5" r="12" fill="#4CAF50"/><circle cx="37.5" cy="50.5" r="12" fill="#03A9F4"/><circle cx="15.5" cy="44.5" r="12" fill="#673AB7"/><circle cx="14" cy="22" r="12" fill="#F44336"/><circle cx="36" cy="14" r="12" fill="#FFEB3B"/></g></svg>

After

Width:  |  Height:  |  Size: 785 B

1
public/logo.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="520" height="160" viewBox="0 0 260 80"><defs><clipPath id="pentagon"><path d="m38.802 1.632 23.656 29.212-20.473 31.524-36.307-9.729L3.71 15.102z"/></clipPath><filter id="blur"><feGaussianBlur stdDeviation="15"/></filter></defs><g clip-path="url(#pentagon)" transform="matrix(.6 0 0 .6 129 36)"><g filter="url(#blur)"><circle cy="10" r="39" fill="#F44336"/><circle cx="45" cy="-5" r="39" fill="#FFEB3B"/><circle cx="70" cy="25" r="39" fill="#4CAF50"/><circle cx="50" cy="65" r="39" fill="#03A9F4"/><circle cx="5" cy="70" r="39" fill="#673AB7"/><circle cx="50" cy="31.5" r="12" fill="#4CAF50"/><circle cx="37.5" cy="50.5" r="12" fill="#03A9F4"/><circle cx="15.5" cy="44.5" r="12" fill="#673AB7"/><circle cx="14" cy="22" r="12" fill="#F44336"/><circle cx="36" cy="14" r="12" fill="#FFEB3B"/></g></g><style>@media (prefers-color-scheme:dark){#text{fill:#fff}}</style><path id="text" fill="#000" d="M29.39 27.758h8.387C37.732 21.412 32.85 17.24 25.04 17.24c-7.678 0-13.092 4.127-13.047 10.251 0 5.06 3.461 7.855 9.186 9.098l3.24.665c3.594.8 4.792 1.687 4.836 3.196-.044 1.553-1.464 2.707-4.304 2.707-3.328 0-5.325-1.598-5.458-4.571H11.15c.044 8.12 5.547 11.76 13.934 11.76 8.21 0 13.091-3.55 13.136-9.896-.045-4.926-2.974-8.388-10.074-9.897l-2.663-.576c-3.062-.666-4.437-1.554-4.349-3.107 0-1.42 1.199-2.44 3.906-2.44 2.84 0 4.171 1.242 4.349 3.328zm21.002 8.564c0-2.396 1.375-3.816 3.505-3.816 2.22 0 3.506 1.42 3.462 3.816v13.624h8.698V34.503c.044-5.28-3.329-9.097-8.432-9.097-3.594 0-6.213 1.864-7.322 4.926h-.222V17.684h-8.387v32.262h8.698zm26.723 14.024c3.15 0 5.503-1.11 6.967-3.817h.222v3.417h8.121V33.35c0-4.438-4.26-7.943-11.183-7.943-7.233 0-10.783 3.816-11.094 8.21h8.032c.178-1.51 1.287-2.22 2.973-2.22 1.51 0 2.574.71 2.574 1.953v.089c0 1.376-1.553 1.82-5.636 2.13-4.97.355-8.875 2.396-8.875 7.677 0 4.837 3.24 7.1 7.9 7.1zm2.84-5.503c-1.509 0-2.53-.71-2.53-2.086 0-1.242.888-2.219 2.885-2.53 1.376-.221 2.574-.488 3.462-.887v2.041c0 2.22-1.864 3.462-3.817 3.462zm16.641 5.103h8.698V37.343c0-2.796 1.908-4.615 4.482-4.615.888 0 2.308.133 3.195.444V25.76a7.486 7.486 0 0 0-2.219-.355c-2.574 0-4.57 1.553-5.458 4.926h-.266V25.76h-8.432v24.185zm29.417.444c6.7 0 11.05-3.195 11.849-8.254h-7.944c-.488 1.376-1.952 2.13-3.728 2.13-2.573 0-4.082-1.686-4.082-4.038v-.355h15.754V37.83c0-7.677-4.704-12.425-12.027-12.425-7.5 0-12.292 5.014-12.292 12.514 0 7.81 4.704 12.47 12.47 12.47zm-3.905-15.31c.044-2.086 1.775-3.55 3.905-3.55 2.174 0 3.816 1.464 3.86 3.55zm35.893 14.866h8.743V37.343h12.558v-7.056h-12.558V24.74h13.934v-7.056h-22.677v32.262zm35.859.444c6.7 0 11.05-3.195 11.848-8.254h-7.944c-.488 1.376-1.952 2.13-3.727 2.13-2.574 0-4.083-1.686-4.083-4.038v-.355h15.754V37.83c0-7.677-4.704-12.425-12.026-12.425-7.5 0-12.293 5.014-12.293 12.514 0 7.81 4.704 12.47 12.47 12.47zm-3.906-15.31c.044-2.086 1.775-3.55 3.905-3.55 2.175 0 3.817 1.464 3.861 3.55zm28.042 15.177c3.417 0 5.725-1.82 6.746-4.26h.177v3.95h8.654V17.683h-8.698v12.293h-.133c-.932-2.486-3.196-4.571-6.79-4.571-4.793 0-9.452 3.683-9.452 12.425 0 8.388 4.349 12.426 9.496 12.426zm3.24-6.657c-2.397 0-3.817-2.174-3.817-5.769s1.42-5.724 3.817-5.724 3.816 2.13 3.816 5.724c0 3.55-1.42 5.77-3.816 5.77zm16.638 6.346h8.698V25.761h-8.698zm4.349-26.715c2.352 0 4.26-1.775 4.26-3.994 0-2.174-1.908-3.95-4.26-3.95-2.397 0-4.305 1.776-4.305 3.95 0 2.22 1.908 3.994 4.305 3.994z"/><path fill="#fff" d="M140.44 64.724h14.463v-4.088h-7.374v-.104l1.785-1.475c4.27-3.57 5.382-5.433 5.382-7.606 0-3.493-2.872-5.795-7.4-5.795-4.372 0-7.218 2.432-7.218 6.39h4.864c-.026-1.578.957-2.458 2.354-2.458 1.423 0 2.406.88 2.406 2.303 0 1.345-.853 2.199-2.225 3.363l-7.037 5.796v3.674z"/></svg>

After

Width:  |  Height:  |  Size: 3.6 KiB

View file

@ -3,6 +3,8 @@ Allow: /$
Disallow: / Disallow: /
# Following borrowed from https://seirdy.one/robots.txt # Following borrowed from https://seirdy.one/robots.txt
# SPDX-FileCopyrightText: © 2023 Rohan Kumar <seirdy@seirdy.one>
# SPDX-License-Identifier: ISC
# I opt out of online advertising so malware that injects ads on my site won't get paid. # I opt out of online advertising so malware that injects ads on my site won't get paid.
# You should do the same. # You should do the same.

View file

@ -1,6 +1,8 @@
{ {
"name": "toot", "name": "Share₂Fedi",
"short_name": "toot", "short_name": "Share₂Fedi",
"background_color": "#000",
"display": "standalone",
"icons": [ "icons": [
{ {
"src": "/icon-192.png", "src": "/icon-192.png",
@ -13,5 +15,5 @@
"type": "image/png" "type": "image/png"
} }
], ],
"theme_color": "#3088d4" "theme_color": "#40665c"
} }

23
script/build-icons Executable file
View file

@ -0,0 +1,23 @@
#!/bin/bash
# This file is part of Share₂Fedi
# https://github.com/kytta/share2fedi
#
# SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
# SPDX-License-Identifier: AGPL-3.0-only
# This script converts raw SVG icons to favicons according to the article:
# https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs
set -euo pipefail
if ! type "magick"; then
echo "ImageMagick ('magick') not found; exiting"
exit 1
fi
node script/icons.js
magick convert public/favicon-32.png public/favicon-16.png public/favicon.ico
rm public/favicon-32.png public/favicon-16.png
echo "Done."

47
script/icons.js Normal file
View file

@ -0,0 +1,47 @@
/*!
* This file is part of Share₂Fedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import sharp from "sharp";
import { optimize } from "svgo";
const pentagon = join(".", "assets", "pentagon.svg");
const smallLogo = join(".", "assets", "s2f.svg");
const outputDirectory = join(".", "public");
try {
await Promise.all([
sharp(pentagon).resize(32).toFile(join(outputDirectory, "favicon-32.png")),
sharp(pentagon).resize(16).toFile(join(outputDirectory, "favicon-16.png")),
sharp(smallLogo)
.resize(140)
.extend({
top: 20,
bottom: 20,
left: 20,
right: 20,
background: "#000",
})
.flatten({ background: "#000" })
.toFile(join(outputDirectory, "apple-touch-icon.png")),
sharp(smallLogo).resize(192).toFile(join(outputDirectory, "icon-192.png")),
sharp(smallLogo).resize(512).toFile(join(outputDirectory, "icon-512.png")),
]);
} catch (error) {
console.error(error);
}
writeFileSync(
join(outputDirectory, "icon.svg"),
optimize(readFileSync(pentagon), {
path: pentagon,
multipass: true,
}).data,
);

View file

@ -0,0 +1,169 @@
---
/*!
* This file is part of Share₂Fedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
const { instance, errors } = Astro.props;
---
<datalist id="popular-instances"></datalist>
<label
class="mt1r"
data-translate="instance"
>
Fediverse instance
<div class="instance-input">
<span id="https-label">https://</span>
<input
type="text"
name="instance"
id="instance"
list="popular-instances"
required
aria-invalid={Boolean(errors)}
aria-errormessage={errors ? "instance-error" : undefined}
aria-describedby="https-label"
value={instance}
/>
</div>
{
errors && (
<p
class="error"
id="instance-error"
aria-live="assertive"
>
{errors}
</p>
)
}
</label>
<div
id="saved-instances"
class="mt1r"
data-translate="previouslyUsed"
>
Previously used:
<span class="list"></span>
</div>
<label
class="mt1r"
for="remember"
data-translate="rememberInstance"
>
<input
type="checkbox"
id="remember"
name="remember"
/>
Remember instance on this device<noscript>.</noscript>
<noscript style="color:darkred;font-size:smaller">
This will not work when JavaScript is disabled.</noscript
>
</label>
<style lang="scss">
.instance-input {
position: relative;
display: flex;
flex-wrap: wrap;
align-items: stretch;
width: 100%;
span {
display: flex;
align-items: center;
padding: 0.5rem;
font-size: 1rem;
}
input[type="text"] {
position: relative;
flex: 1 1 auto;
width: 1%;
}
}
#saved-instances {
margin-bottom: 1rem;
> div {
display: inline-block;
}
:global(span.link) {
color: var(--s2f-accent-color-contrast);
cursor: pointer;
text-decoration: 1px solid underline currentColor;
}
}
</style>
<script>
import { getUrlDomain, normalizeURL } from "@lib/url";
import { $popularInstances } from "@stores/popular-instances";
import { $savedInstances, save } from "@stores/saved-instances";
const instanceElement = document.querySelector(
"#instance",
) as HTMLInputElement;
const savedInstancesElement = document.querySelector(
"#saved-instances",
) as HTMLDivElement;
$savedInstances.subscribe((instances) => {
if (instances.size === 0) {
savedInstancesElement.style.display = "none";
return;
}
const savedInstances = [...instances];
if (!instanceElement.value) {
instanceElement.value = getUrlDomain(savedInstances[0] as string);
}
savedInstancesElement.style.display = "block";
document.querySelector("#saved-instances>.list")!.replaceChildren(
...savedInstances
.flatMap((instance: string) => {
if (!instance) {
return [];
}
const host = getUrlDomain(instance);
const element = document.createElement("span");
element.classList.add("link");
element.textContent = host;
element.addEventListener("click", () => {
instanceElement.value = host;
});
return [element, ", "];
})
.slice(0, -1),
);
});
document.querySelector("#form")!.addEventListener("submit", (event) => {
const formData = new FormData(event.target as HTMLFormElement);
if (formData.get("remember")) {
save(normalizeURL(formData.get("instance") as string));
}
return true;
});
$popularInstances.subscribe((instances) => {
document.querySelector("#popular-instances")!.replaceChildren(
...instances.map((domain) => {
const option = document.createElement("option");
option.value = domain;
return option;
}),
);
});
</script>

View file

@ -0,0 +1,58 @@
---
/*!
* This file is part of Share₂Fedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { languages } from "@i18n/translations";
const initialLanguage = "en";
---
<label data-translate="language">
Language:
<select
name="language"
id="language"
>
{
Object.entries(languages).map(([k, v]) => {
return (
<option
selected={k === initialLanguage}
value={k}
>
{v}
</option>
);
})
}
</select>
</label>
<script>
import { findBestLanguage } from "@i18n/engine";
import { applyTranslations } from "@i18n/engine";
import { $locale } from "@stores/i18n";
const select: HTMLSelectElement = document.querySelector("#language")!;
document.addEventListener("DOMContentLoaded", () => {
$locale.subscribe((newLocale) => {
if (newLocale === undefined) {
newLocale = findBestLanguage();
}
applyTranslations(newLocale);
if (select.value !== newLocale) {
select.value = newLocale;
}
});
select.addEventListener("change", (event) => {
$locale.set((event.target as typeof select).value);
});
});
</script>

View file

@ -0,0 +1,23 @@
<!--
This file is part of Share₂Fedi
https://github.com/kytta/share2fedi
SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
SPDX-License-Identifier: CC0-1.0
-->
<details>
<summary data-translate="licence">Licence</summary>
<p data-translate="licence1">
Share₂Fedi is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License, version 3, as published
by the Free Software Foundation.
</p>
<p data-translate="licence2">
Share₂Fedi 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.
</p>
</details>

View file

@ -0,0 +1,28 @@
<!--
This file is part of Share₂Fedi
https://github.com/kytta/share2fedi
SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
SPDX-License-Identifier: CC0-1.0
-->
<details>
<summary data-translate="privacyNotice">Privacy Notice</summary>
<p data-translate="privacy1">
s2f.kytta.dev is hosted on Vercel. Vercel processes IP addresses, system
configuration information, and other information about traffic to and from
s2f.kytta.dev. Vercel does not store this information nor does it get shared
with third parties. See
<a
href="https://vercel.com/legal/privacy-policy#customers"
data-translate="vercelPP"
>Vercels privacy policy</a
>
for more information.
</p>
<p data-translate="privacy2">
When you click the Publish button, youll get redirected to a Fediverse
instance youve specified. It may process and/or store your data. Please
refer to the privacy policy of the respective instance.
</p>
</details>

View file

@ -1,61 +0,0 @@
/*!
* @source: https://codeberg.org/kytta/toot/src/branch/main/src/count.js
*
* @licstart The following is the entire license notice for the
* JavaScript code in this page.
*
* toot - Cross-instance share page for Mastodon
* Copyright (C) 2022 Nikita Karamov <me@kytta.dev>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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/>.
*
* @licend The above is the entire license notice
* for the JavaScript code in this page.
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
// This is the analytics code for toot. It just sends a beacon to GoatCounter
// with hardcoded path. This is way more lightweight, performant
// and privacy-friendly than the default GC script.
// Check if the default GC URL resolves
// This allows us to not track people with ad blockers
if (
window.location.host === "toot.kytta.dev" ||
window.location.host === "s2f.kytta.dev" ||
window.location.host === "share2fedi.kytta.dev"
) {
// eslint-disable-next-line unicorn/prefer-top-level-await
fetch("//gc.zgo.at/", { method: "HEAD" }).then((result) => {
if (!result.ok) {
return;
}
const screen = encodeURIComponent(
[
window.screen.width,
window.screen.height,
window.devicePixelRatio || 1,
].join(",")
);
const random = encodeURIComponent(Math.random().toString(36).slice(2));
navigator.sendBeacon(
`https://share2fedi.goatcounter.com/count?p=%2F&s=${screen}&b=0&rnd=${random}`
);
});
}

9
src/env.d.ts vendored Normal file
View file

@ -0,0 +1,9 @@
/* eslint-disable unicorn/prevent-abbreviations */
/*!
* This file is part of ShareFedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: CC0-1.0
*/
/// <reference types="astro/client" />

74
src/i18n/engine.ts Normal file
View file

@ -0,0 +1,74 @@
/*!
* This file is part of ShareFedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { strings, defaultLanguage, languages } from "./translations";
export function useTranslations(language: string) {
if (!(language in strings)) {
language = defaultLanguage;
}
return function t(
key: keyof (typeof strings)[typeof defaultLanguage],
): string {
return (
strings[language as keyof typeof strings][key] ||
strings[defaultLanguage][key] ||
""
);
};
}
export function findBestLanguage(): string {
const urlLanguage = new URLSearchParams(window.location.search).get("lang");
if (urlLanguage && urlLanguage in languages) {
return urlLanguage;
}
let browserLanguages = navigator.languages;
if (!navigator.languages) browserLanguages = [navigator.language];
for (const language of browserLanguages) {
const locale = new Intl.Locale(language);
const minimized = locale.minimize();
for (const candidate of [locale.baseName, minimized.baseName]) {
if (candidate in languages) {
return candidate;
}
}
}
return defaultLanguage;
}
export function applyTranslations(language: string) {
const t = useTranslations(language);
for (const node of document.querySelectorAll("[data-translate]")) {
const dataset = (node as HTMLElement).dataset;
if (dataset.translateAttribute) {
node.setAttribute(dataset.translateAttribute, t(dataset.translate!));
continue;
}
let splitTranslated = t(dataset.translate!).split("{}");
if (splitTranslated.length === 1) {
node.innerHTML = t(dataset.translate!);
continue;
}
// XXX: this is needed for the strings where the placholder sits at the very
// beginning, which introduces phantom empty strings.
splitTranslated = splitTranslated.filter((string) => string !== "");
for (const child of node.childNodes) {
if (child.nodeType === Node.TEXT_NODE) {
child.textContent = splitTranslated.shift() || "";
}
}
}
}

31
src/i18n/translations.ts Normal file
View file

@ -0,0 +1,31 @@
/*!
* This file is part of ShareFedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
import de from "./translations/de.json";
import en from "./translations/en.json";
import es from "./translations/es.json";
import fr from "./translations/fr.json";
import ru from "./translations/ru.json";
export const languages = {
en: "English",
de: "Deutsch",
es: "Español",
fr: "Français",
ru: "Русский",
};
export const strings: Record<keyof typeof languages, Record<string, string>> = {
en,
de,
es,
fr,
ru,
} as const;
export const defaultLanguage: keyof typeof strings = "en";

View file

@ -0,0 +1,25 @@
{
"metaDescription": "Share₂Fedi ist eine Share-Seite für Mastodon, Misskey, Friendica und andere. Geben Sie Ihren Beitragstext und die Instanz-URL ein und klicken Sie auf „Veröffentlichen“!",
"language": "Sprache: {}",
"description": "Share₂Fedi ist eine instanzunabhängige Share-Seite für {}. Mit ihr können Sie von einer einzigen Seite aus auf verschiedenen föderierten Plattformen posten.",
"fediverse": "das Fediverse",
"supportedProjects": "Unterstützte Projekte:",
"incl": "inkl.",
"credits": "Share₂Fedi wird von {} entwickelt und gepflegt. Der Quellcode ist {}. Gehostet mit {}. {}.",
"nikita": "Nikita Karamov",
"onGitHub": "auf GitHub",
"statusPage": "Statusseite",
"licence": "Lizenz",
"licence1": "Share₂Fedi ist freie Software: Sie können es unter den Bedingungen der GNU Affero General Public License, wie von der Free Software Foundation veröffentlicht, weitergeben und/oder modifizieren, entweder gemäß Version 3 der Lizenz oder (nach Ihrer Option) jeder späteren Version.",
"licence2": "Die Veröffentlichung von Share₂Fedi erfolgt in der Hoffnung, dass es Ihnen von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FÜR EINEN BESTIMMTEN ZWECK. Details finden Sie in der GNU Affero General Public License.",
"privacyNotice": "Datenschutzhinweis",
"privacy1": "s2f.kytta.dev wird auf Vercel gehostet. Vercel verarbeitet IP-Adressen, Systemkonfigurationsinformationen und andere Informationen über den Verkehr von und zu s2f.kytta.dev. Vercel speichert diese Informationen nicht und gibt sie auch nicht an Dritte weiter. Siehe {} für weitere Informationen.",
"privacy2": "Wenn Sie auf die „Veröffentlichen“ klicken, werden Sie zu einer Fediverse-Instanz weitergeleitet, die Sie angegeben haben. Diese kann Ihre Daten verarbeiten und/oder speichern. Bitte beachten Sie die Datenschutzrichtlinien der jeweiligen Instanz.",
"vercelPP": "Vercels Datenschutzpolitik",
"postText": "Beitragstext{}",
"postTextPlaceholder": "Was gibts Neues?",
"instance": "Fediverse-Instanz{}",
"previouslyUsed": "Bisher verwendet: {}",
"rememberInstance": "{} Instanz auf diesem Gerät merken",
"publish": "Veröffentlichen"
}

View file

@ -0,0 +1,25 @@
{
"metaDescription": "Share₂Fedi is a share page for Mastodon, Misskey, Friendica, and others. Type in your post text and the instance URL and click Publish!",
"language": "Language: {}",
"description": "Share₂Fedi is an instance-agnostic share page for {}. With it, you can post to various federated platforms from a single page.",
"fediverse": "the Fediverse",
"supportedProjects": "Supported projects:",
"incl": "incl.",
"credits": "Share₂Fedi is developed and maintained by {}. Source code is {}. Hosted with {}. {}.",
"nikita": "Nikita Karamov",
"onGitHub": "on GitHub",
"statusPage": "Status page",
"licence": "Licence",
"licence1": "Share₂Fedi is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License, version 3, as published by the Free Software Foundation.",
"licence2": "Share₂Fedi 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.",
"privacyNotice": "Privacy Notice",
"privacy1": "s2f.kytta.dev is hosted on Vercel. Vercel processes IP addresses, system configuration information, and other information about traffic to and from s2f.kytta.dev. Vercel does not store this information nor does it get shared with third parties. See {} for more information.",
"privacy2": "When you click the Publish button, youll get redirected to a Fediverse instance youve specified. It may process and/or store your data. Please refer to the privacy policy of the respective instance.",
"vercelPP": "Vercels privacy policy",
"postText": "Post text{}",
"postTextPlaceholder": "Whats on your mind?",
"instance": "Fediverse instance{}",
"previouslyUsed": "Previously used: {}",
"rememberInstance": "{} Remember instance on this device",
"publish": "Publish"
}

View file

@ -0,0 +1,25 @@
{
"metaDescription": "Share₂Fedi es una página de compartir para Mastodon, Misskey, Friendica y otros. ¡Escriba su texto de publicación y la URL de la instancia y haga clic en «Publicar»!",
"language": "Idioma: {}",
"description": "Share₂Fedi es una página de compartir independiente de la instancia para {}. Con ella, puede publicar en varias plataformas federadas desde una sola página.",
"fediverse": "el Fediverso",
"supportedProjects": "Proyectos compatibles:",
"incl": "incl.",
"credits": "Share₂Fedi es desarrollado y mantenido por {}. El código fuente es {}. Alojado con {}. {}.",
"nikita": "Nikita Karamov",
"onGitHub": "en GitHub",
"statusPage": "Página de estado",
"licence": "Licencia",
"licence1": "Share₂Fedi es software libre: puede redistribuirlo y/o modificarlo bajo los términos de la Licencia Pública General Affero de GNU, publicada por la Free Software Foundation, ya sea la versión 3 de la Licencia, o (a su elección) cualquier versión posterior.",
"licence2": "Share₂Fedi se distribuye con la esperanza de que sea útil, pero SIN NINGUNA GARANTÍA; sin siquiera la garantía implícita de COMERCIABILIDAD o IDONEIDAD PARA UN PROPÓSITO PARTICULAR. Consulte la Licencia Pública General Affero de GNU para obtener más detalles.",
"privacyNotice": "Aviso de privacidad",
"privacy1": "s2f.kytta.dev está alojado en Vercel. Vercel procesa las direcciones IP, la información de configuración del sistema y otra información sobre el tráfico hacia y desde s2f.kytta.dev. Vercel no almacena esta información ni la comparte con terceros. Consulte {} para obtener más información.",
"privacy2": "Cuando hace clic en el botón «Publicar», se le redirige a una instancia de Fediverso que ha especificado. Puede procesar y/o almacenar sus datos. Consulte la política de privacidad de la instancia correspondiente.",
"vercelPP": "Política de privacidad de Vercel",
"postText": "Texto de la publicación{}",
"postTextPlaceholder": "¿Qué hay de nuevo?",
"instance": "Instancia del Fediverso{}",
"previouslyUsed": "Usado anteriormente: {}",
"rememberInstance": "{} Recordar instancia en este dispositivo",
"publish": "Publicar"
}

View file

@ -0,0 +1,25 @@
{
"metaDescription": "Share₂Fedi est une page de partage pour Mastodon, Misskey, Friendica et autres. Tapez votre texte de publication et lURL de linstance, puis cliquez sur « Publier » !",
"language": "Langue : {}",
"description": "Share₂Fedi est une page de partage indépendante pour {}. Avec elle, vous pouvez publier sur diverses plateformes fédérées depuis une seule page.",
"fediverse": "le Fediverse",
"supportedProjects": "Projets pris en charge :",
"incl": "dont",
"credits": "Share₂Fedi est développé et maintenu par {}. Le code source est {}. Hébergé avec {}. {}.",
"nikita": "Nikita Karamov",
"onGitHub": "sur GitHub",
"statusPage": "Page de statut",
"licence": "Licence",
"licence1": "Share₂Fedi est un logiciel libre : vous pouvez le redistribuer et/ou le modifier selon les termes de la licence publique générale Affero de la Free Software Foundation, telle que publiée par la Free Software Foundation, soit la version 3 de la licence, soit (à votre choix) toute version ultérieure.",
"licence2": "Share₂Fedi est distribué dans lespoir quil sera utile, mais SANS AUCUNE GARANTIE ; sans même la garantie implicite de QUALITÉ MARCHANDE ou DADÉQUATION À UN USAGE PARTICULIER. Consultez la licence publique générale Affero de GNU pour plus de détails.",
"privacyNotice": "Avis de confidentialité",
"privacy1": "s2f.kytta.dev est hébergé sur Vercel. Vercel traite les adresses IP, les informations de configuration système et dautres informations sur le trafic vers et depuis s2f.kytta.dev. Vercel ne stocke pas ces informations et ne les partage pas avec des tiers. Voir {} pour plus dinformations.",
"privacy2": "Lorsque vous cliquez sur le bouton « Publier », vous êtes redirigé vers une instance du Fediverse que vous avez spécifiée. Elle peut traiter et/ou stocker vos données. Veuillez vous référer à la politique de confidentialité de linstance respective.",
"vercelPP": "Politique de confidentialité de Vercel",
"postText": "Texte de la publication{}",
"postTextPlaceholder": "Quoi de neuf ?",
"instance": "Instance du Fediverse{}",
"previouslyUsed": "Utilisé précédemment : {}",
"rememberInstance": "{} Se souvenir de linstance sur cet appareil",
"publish": "Publier"
}

View file

@ -0,0 +1,25 @@
{
"metaDescription": "Share₂Fedi — это share-страница для Mastodon, Misskey, Friendica и других сервисов. Введите текст поста и URL-адрес инстанса и нажмите «Опубликовать»!",
"language": "Язык: {}",
"description": "Share₂Fedi — это инстанс-независимая share-страница для {}. С её помощью вы можете делиться информацией на различных федеративных платформах с одной страницы.",
"fediverse": "Федивёрса",
"supportedProjects": "Поддерживаемые проекты:",
"incl": "вкл.",
"credits": "Share₂Fedi разрабатывается и поддерживается {}. Исходный код {}. Хостится на {}. {}.",
"nikita": "Никитой Карамовым",
"onGitHub": "на GitHub",
"statusPage": "Статус",
"licence": "Лицензия",
"licence1": "Share₂Fedi является свободным программным обеспечением: вы можете распространять её и (или) изменять, соблюдая условия GNU Affero General Public License, опубликованной Free Software Foundation; либо редакции 3 Лицензии, либо (на ваше усмотрение) любой редакции, выпущенной позже.",
"licence2": "Share₂Fedi распространяется в расчёте на то, что она окажется полезной, но БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ, включая подразумеваемую гарантию КАЧЕСТВА либо ПРИГОДНОСТИ ДЛЯ ОПРЕДЕЛЁННЫХ ЦЕЛЕЙ. Ознакомьтесь с GNU Affero General Public License для получения более подробной информации.",
"privacyNotice": "Политика конфиденциальности",
"privacy1": "Сайт s2f.kytta.dev размещён на серверах Vercel. Vercel обрабатывает IP-адреса, информацию о конфигурации системы и другую информацию о трафике, идущем к s2f.kytta.dev и от него. Vercel не хранит эту информацию и не передает её третьим лицам. Более подробную информацию см. в {}.",
"privacy2": "Когда вы нажимаете кнопку «Опубликовать», вы попадаете на указанный вами инстанс Федивёрса. Он может обрабатывать и/или хранить ваши данные. Пожалуйста, ознакомьтесь с политикой конфиденциальности соответствующего инстанса.",
"vercelPP": "Политике конфиденциальности Vercel",
"postText": "Текст поста{}",
"postTextPlaceholder": "О чём думаете?",
"instance": "Инстанс Федивёрса{}",
"previouslyUsed": "Ранее использовались: {}",
"rememberInstance": "{} Запомнить инстанс на этом устройстве",
"publish": "Опубликовать"
}

View file

@ -1,97 +0,0 @@
<!--
@source: https://codeberg.org/kytta/toot/src/branch/main/src/index.html
toot - Cross-instance share page for Mastodon
Copyright (C) 2020-2022 Nikita Karamov <me@kytta.dev>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
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/>.
SPDX-License-Identifier: AGPL-3.0-or-later
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>toot &mdash; cross-instance share page for Mastodon</title>
<meta
name="description"
content="toot allows you to share stuff on Mastodon, cross-instance. Just put in your post text and the instance URL and click &lsquo;Toot!&rsquo;"
/>
<link rel="canonical" href="https://toot.kytta.dev/" />
<link href="/style.css" rel="stylesheet" />
<link href="/favicon.ico" rel="icon" type="image/x-icon" />
<link href="/apple-touch-icon.png" rel="icon" type="image/svg+xml" />
<link href="/apple-touch-icon.png" rel="apple-touch-icon" />
<link href="/site.webmanifest" rel="manifest" />
<meta name="theme-color" content="#3088d4" />
</head>
<body>
<header>
<h1>
<img src="/icon.svg" alt="toot" width="72" height="72" />
</h1>
<p>
for
<img src="/mastodon.svg" alt="Mastodon" width="95.5" height="27" />
</p>
</header>
<main>
<form action="/api/toot" method="POST" onsubmit="onFormSubmit(this)">
<section>
<label for="text">Post text</label>
<textarea
name="text"
id="text"
rows="6"
placeholder="What's on your mind?"
required
></textarea>
</section>
<section>
<datalist id="instanceDatalist"></datalist>
<label for="instance">Choose your Mastodon instance</label>
<input
type="url"
name="instance"
id="instance"
placeholder="https://"
list="instanceDatalist"
required
/>
</section>
<section class="remember">
<input type="checkbox" id="remember" name="remember" />
<label for="remember">Remember my instance on this device</label>
</section>
<section class="submit">
<input type="submit" value="TOOT!" />
</section>
</form>
</main>
<footer>
<section>
<a href="https://joinmastodon.org/">What is Mastodon?</a>
</section>
<section>
<a href="https://codeberg.org/kytta/toot">toot on Codeberg</a>
</section>
</footer>
<script src="/main.js"></script>
<script src="/count.js" async defer></script>
</body>
</html>

146
src/layouts/layout.astro Normal file
View file

@ -0,0 +1,146 @@
---
/*!
* This file is part of Share₂Fedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
import "@styles/main.scss";
import LanguageSelect from "@components/language-select.astro";
import Licence from "@components/licence.html";
import Privacy from "@components/privacy.html";
import package_ from "../../package.json";
---
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<title>Share₂Fedi</title>
<meta
name="description"
content="Share₂Fedi is a share page for Mastodon, Misskey, Friendica, and others. Type in your post text and the instance URL and click Publish!"
data-translate="metaDescription"
data-translate-attribute="content"
/>
<link
rel="canonical"
href={Astro.url}
/>
<meta
property="og:title"
content="Share₂Fedi, a share page for the Fediverse"
/>
<meta
property="og:type"
content="website"
/>
<meta
property="og:image"
content="/banner.png"
/>
<meta
property="og:url"
content={`${Astro.url}banner.png`}
/>
<link
rel="icon"
href="/favicon.ico"
sizes="32x32"
/>
<link
rel="icon"
href="/icon.svg"
type="image/svg+xml"
/>
<link
rel="apple-touch-icon"
href="/apple-touch-icon.png"
/>
<link
rel="manifest"
href="/site.webmanifest"
/>
<meta
name="generator"
content={Astro.generator}
/>
<meta
itemprop="version"
content={package_.version}
/>
</head>
<header>
<img
src="/logo.svg"
alt="Share2Fedi"
width="195"
height="60"
/>
<LanguageSelect />
</header>
<body>
<main>
<slot />
</main>
<aside>
<p data-translate="description">
Share₂Fedi is an instance-agnostic share page for
<a
href="https://en.wikipedia.org/wiki/Fediverse"
data-translate="fediverse"
>the Fediverse</a
>. With it, you can post to various federated platforms from a single
page.
</p>
<p><b data-translate="supportedProjects">Supported projects:</b></p>
<ul>
<li>
Mastodon (<span data-translate="incl">incl.</span> Hometown, Fedibird,
GlitchCafé)
</li>
<li>
Misskey (<span data-translate="incl">incl.</span> Firefish/Calckey,
FoundKey, Meisskey)
</li>
<li>Friendica</li>
<li>Hubzilla</li>
<li>GNU Social</li>
</ul>
<p data-translate="credits">
Share₂Fedi is developed and maintained by
<a
href="https://www.kytta.dev/"
data-translate="nikita"
>Nikita Karamov</a
>. Source code is
<a
href="https://github.com/kytta/share2fedi"
data-translate="onGitHub"
>on GitHub</a
>. Hosted with
<a href="https://vercel.com">Vercel</a>.
<a
href="https://stats.uptimerobot.com/QOXj3uXPDX"
data-translate="statusPage"
>Status page</a
>.
</p>
<Licence />
<Privacy />
</aside>
</body>
</html>

59
src/lib/instance.ts Normal file
View file

@ -0,0 +1,59 @@
/*!
* This file is part of ShareFedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { supportedProjects } from "./project";
interface Instance {
domain: string;
score: number;
active_users_monthly: number;
total_users: number;
}
const getInstancesForProject = async (
project: keyof typeof supportedProjects,
): Promise<Instance[]> => {
let instances: Instance[];
try {
const response = await fetch("https://api.fediverse.observer/", {
headers: {
Accept: "*/*",
"Accept-Language": "en;q=1.0",
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `{nodes(status:"UP",softwarename:"${project}"){domain score active_users_monthly total_users}}`,
}),
method: "POST",
});
const json = await response.json();
instances = json.data.nodes;
} catch (error) {
console.error(`Could not fetch instances for "${project}"`, error);
return [];
}
return instances.filter(
(instance) =>
instance.score > 90 &&
// sanity check for some spammy-looking instances
instance.total_users >= instance.active_users_monthly,
);
};
export const getPopularInstanceDomains = async (): Promise<string[]> => {
const instancesPerProject = await Promise.all(
Object.keys(supportedProjects).map((project) =>
getInstancesForProject(project),
),
);
const instances = instancesPerProject.flat();
instances.sort((a, b) => b.active_users_monthly - a.active_users_monthly);
return instances.slice(0, 200).map((instance) => instance.domain);
};

60
src/lib/nodeinfo.ts Normal file
View file

@ -0,0 +1,60 @@
/*!
* This file is part of ShareFedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { normalizeURL } from "@lib/url";
interface NodeInfoList {
links: {
rel: string;
href: string;
}[];
}
interface NodeInfo {
software: {
name: string;
version: string;
[key: string]: unknown;
};
[key: string]: unknown;
}
export const getSoftwareName = async (
domain: string,
): Promise<string | undefined> => {
const nodeInfoListUrl = new URL(
"/.well-known/nodeinfo",
normalizeURL(domain),
);
let nodeInfoList: NodeInfoList;
try {
const nodeInfoListResponse = await fetch(nodeInfoListUrl);
nodeInfoList = await nodeInfoListResponse.json();
} catch (error) {
console.error("Could not fetch '.well-known/nodeinfo':", error);
return undefined;
}
for (const link of nodeInfoList.links) {
if (
/^http:\/\/nodeinfo\.diaspora\.software\/ns\/schema\/(1\.0|1\.1|2\.0|2\.1)/.test(
link.rel,
)
) {
const nodeInfoResponse = await fetch(link.href);
const nodeInfo = (await nodeInfoResponse.json()) as NodeInfo;
return nodeInfo.software.name;
}
}
// not found
console.warn("No NodeInfo found for domain:", domain);
return undefined;
};

64
src/lib/project.ts Normal file
View file

@ -0,0 +1,64 @@
/*!
* This file is part of ShareFedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
export interface ProjectPublishConfig {
endpoint: string;
params: {
text: string;
};
}
const mastodonConfig: ProjectPublishConfig = {
endpoint: "share",
params: {
text: "text",
},
};
const misskeyConfig: ProjectPublishConfig = {
endpoint: "share",
params: {
text: "text",
},
};
/**
* Mapping of the supported fediverse projects.
*
* The keys of this mapping can be used as keys for the fediverse.observer API,
* icon names, etc.
*/
export const supportedProjects: Record<string, ProjectPublishConfig> = {
calckey: misskeyConfig,
fedibird: mastodonConfig,
firefish: misskeyConfig,
foundkey: misskeyConfig,
friendica: {
endpoint: "compose",
params: {
text: "body",
},
},
glitchcafe: mastodonConfig,
gnusocial: {
endpoint: "notice/new",
params: {
text: "status_textarea",
},
},
hometown: mastodonConfig,
hubzilla: {
endpoint: "rpost",
params: {
text: "body",
},
},
mastodon: mastodonConfig,
meisskey: misskeyConfig,
misskey: misskeyConfig,
};

30
src/lib/response.ts Normal file
View file

@ -0,0 +1,30 @@
/*!
* This file is part of ShareFedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
export const json = (
body: unknown,
status: number = 200,
headers: Record<string, string> = {},
) => {
return new Response(JSON.stringify(body), {
headers: {
"Content-Type": "application/json",
...headers,
},
status,
});
};
export const error = (message: string, status: number = 400) => {
return json(
{
error: message,
},
status,
);
};

35
src/lib/url.ts Normal file
View file

@ -0,0 +1,35 @@
/*!
* This file is part of ShareFedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
/**
* Adds missing "https://" and ending slash to the URL
*
* @param url URL to normalize
* @return normalized URL
*/
export const normalizeURL = (url: string): string => {
if (!(url.startsWith("https://") || url.startsWith("http://"))) {
url = "https://" + url;
}
if (!url.endsWith("/")) {
url += "/";
}
return url;
};
export const getUrlDomain = (url: string | URL): string => {
if (typeof url === "string") {
url = url.trim();
if (!/^https?:\/\//.test(url)) {
url = `https://${url}`;
}
}
return new URL(url).host;
};

View file

@ -1,140 +0,0 @@
/*!
* @source: https://codeberg.org/kytta/toot/src/branch/main/src/main.js
*
* @licstart The following is the entire license notice for the
* JavaScript code in this page.
*
* toot - Cross-instance share page for Mastodon
* Copyright (C) 2020-2022 Nikita Karamov <me@kytta.dev>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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/>.
*
* @licend The above is the entire license notice
* for the JavaScript code in this page.
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
const INSTANCE_LIST_URL = "https://api.joinmastodon.org/servers";
const LOCAL_STORAGE_KEY = "recentInstances";
const RECENT_INSTANCES_SIZE = 5;
const $instance = document.querySelector("#instance");
const $instanceDatalist = document.querySelector("#instanceDatalist");
/**
* Adds missing "https://" and ending slash to the URL
*
* @param {string} url URL to normalize
* @return {string} normalized URL
*/
function normalizeUrl(url) {
if (!url.includes("http://") && !url.includes("https://")) {
url = "https://" + url;
}
if (url.at(-1) !== "/") {
url = url + "/";
}
return url;
}
function onLoadInstancesError() {
console.error("Couldn't load instance list");
}
function onLoadInstancesSuccess() {
if (this.status >= 400) {
return onLoadInstancesError();
}
const currentInstance = $instance.value;
const instanceDomains = JSON.parse(this.responseText).map(
(index) => index.domain
);
if (currentInstance && !instanceDomains.includes(currentInstance)) {
instanceDomains.push(currentInstance);
}
instanceDomains.sort();
for (const instanceDomain of instanceDomains) {
const $option = document.createElement("option");
$option.value = normalizeUrl(instanceDomain);
$instanceDatalist.append($option);
}
}
function loadInstances() {
if ($instanceDatalist.children.length === 0) {
const request = new XMLHttpRequest();
request.addEventListener("load", onLoadInstancesSuccess);
request.addEventListener("error", onLoadInstancesError);
request.open("GET", INSTANCE_LIST_URL);
request.send();
}
}
function getRecentInstances() {
const storedValue = window.localStorage.getItem(LOCAL_STORAGE_KEY);
if (!storedValue) return [];
return JSON.parse(storedValue);
}
function rememberInstance(instance) {
const recentInstances = getRecentInstances();
const index = recentInstances.indexOf(instance);
if (index >= 0) {
recentInstances.splice(index, 1);
}
recentInstances.unshift(instance);
recentInstances.length = RECENT_INSTANCES_SIZE;
window.localStorage.setItem(
LOCAL_STORAGE_KEY,
JSON.stringify(recentInstances)
);
}
// Used in HTML
// eslint-disable-next-line no-unused-vars
function onFormSubmit(form) {
const formData = new FormData(form);
if (formData.get("remember")) {
rememberInstance(formData.get("instance"));
}
return true;
}
let prefillInstance = getRecentInstances()[0];
const URLParameters = window.location.search.slice(1).split("&");
for (const URLParameter of URLParameters) {
const URLParameterPair = URLParameter.split("=");
if (URLParameterPair[0] === "text") {
document.querySelector("#text").value = decodeURIComponent(
URLParameterPair[1]
);
} else if (URLParameterPair[0] === "instance") {
prefillInstance = decodeURIComponent(URLParameterPair[1]);
}
}
if (prefillInstance != undefined) {
$instance.value = normalizeUrl(prefillInstance);
}
$instance.addEventListener("focus", loadInstances);

View file

@ -0,0 +1,43 @@
/*!
* This file is part of ShareFedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { getSoftwareName } from "@lib/nodeinfo";
import { type ProjectPublishConfig, supportedProjects } from "@lib/project";
import { error, json } from "@lib/response";
import type { APIRoute } from "astro";
export type Detection = {
domain: string;
project: keyof typeof supportedProjects;
} & ProjectPublishConfig;
export const GET: APIRoute = async ({ params }) => {
const domain = params.domain as string;
const softwareName = await getSoftwareName(domain);
if (softwareName === undefined) {
return error("Could not detect Fediverse project.");
}
if (!(softwareName in supportedProjects)) {
return error(`Fediverse project "${softwareName}" is not supported yet.`);
}
const publishConfig = supportedProjects[softwareName] as ProjectPublishConfig;
return json(
{
domain,
project: softwareName,
...publishConfig,
},
200,
{
"Cache-Control": "public, s-maxage=86400, max-age=604800",
},
);
};

View file

@ -0,0 +1,22 @@
/*!
* This file is part of ShareFedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { APIRoute } from "astro";
import { getPopularInstanceDomains } from "@lib/instance";
import { json } from "@lib/response";
export const GET: APIRoute = async () => {
const popularInstanceDomains = await getPopularInstanceDomains();
return json(popularInstanceDomains, 200, {
"Cache-Control":
popularInstanceDomains.length > 0
? "public, s-maxage=86400, max-age=604800"
: "public, s-maxage=60, max-age=3600",
});
};

104
src/pages/index.astro Normal file
View file

@ -0,0 +1,104 @@
---
/*!
* This file is part of Share₂Fedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
import Layout from "@layouts/layout.astro";
import InstanceSelect from "@components/instance-select.astro";
import { getUrlDomain } from "@lib/url";
import type { Detection } from "./api/detect/[domain]";
const searchParameters = new URL(Astro.request.url).searchParams;
let text: string | null = searchParameters.get("text");
let instance: string | null = searchParameters.get("instance");
const errors = { text: "", instance: "" };
if (Astro.request.method === "POST") {
const formData = await Astro.request.formData();
text = formData.get("text") as string | null;
instance = formData.get("instance") as string | null;
if (typeof text !== "string" || text.length === 0) {
errors.text += "Please enter post text. ";
}
let detection: Detection | undefined;
if (typeof instance !== "string" || instance.length === 0) {
errors.instance += "Please enter instance domain. ";
} else {
instance = getUrlDomain(instance);
const detectResponse = await fetch(
new URL(`/api/detect/${instance}`, Astro.url),
);
const detectJson = await detectResponse.json();
if (detectJson.error) {
errors.instance += detectJson.error + " ";
} else {
detection = detectJson;
}
}
const hasErrors = Object.values(errors).some(Boolean);
if (!hasErrors && detection !== undefined) {
const { domain, endpoint, params } = detection;
const publishUrl = new URL(endpoint, `https://${domain}/`);
publishUrl.search = new URLSearchParams([
[params.text, text as string],
]).toString();
// eslint-disable-next-line unicorn/prefer-module
return Astro.redirect(publishUrl.toString(), 303);
}
}
---
<Layout>
<form
id="form"
method="POST"
>
<label data-translate="postText">
Post text
<textarea
name="text"
id="text"
rows="7"
placeholder="Whats on your mind?"
required
aria-invalid={Boolean(errors.text)}
aria-errormessage={errors.text ? "text-error" : undefined}
data-translate="postTextPlaceholder"
data-translate-attribute="placeholder"
>{text}</textarea
>
{
errors.text && (
<p
class="error"
id="text-error"
aria-live="assertive"
>
{errors.text}
</p>
)
}
</label>
<InstanceSelect
{instance}
errors={errors.instance}
/>
<input
type="submit"
value="Publish"
class="mt1r"
data-translate="publish"
data-translate-attribute="value"
/>
</form>
</Layout>

View file

@ -1,38 +0,0 @@
/*
* @source: https://codeberg.org/kytta/toot/src/branch/main/src/scss/_fonts.scss
*
* toot - Cross-instance share page for Mastodon
* Copyright (C) 2020-2022 Nikita Karamov <me@kytta.dev>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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/>.
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
@font-face {
font-family: "Roboto";
font-style: normal;
font-weight: 400;
src: local("Roboto"), url("/fonts/Roboto-400.woff2?v=29") format("woff2"),
url("/fonts/Roboto-400.woff?v=29") format("woff");
}
@font-face {
font-family: "Roboto";
font-style: normal;
font-weight: 500;
src: local("Roboto Medium"), local("Roboto-Medium"),
url("/fonts/Roboto-500.woff2?v=29") format("woff2"),
url("/fonts/Roboto-500.woff?v=29") format("woff");
}

View file

@ -1,35 +0,0 @@
/*
* @source: https://codeberg.org/kytta/toot/src/branch/main/src/scss/_variables.scss
*
* toot - Cross-instance share page for Mastodon
* Copyright (C) 2020-2022 Nikita Karamov <me@kytta.dev>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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/>.
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
$text-font: "Roboto", sans-serif;
$bg: #1f232b;
$text: #9baec8;
$title: #d9e1e8;
$button-bg: #2b90d9;
$button-hover-bg: #56a7e1;
$button-text: white;
$input-bg: #131419;
$border-color: #303643;

View file

@ -1,181 +0,0 @@
/*!
* @source: https://codeberg.org/kytta/toot/src/branch/main/src/scss/style.scss
*
* toot - Cross-instance share page for Mastodon
* Copyright (C) 2020-2022 Nikita Karamov <me@kytta.dev>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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/>.
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
@use "sass:color";
@import "fonts";
@import "variables";
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html,
body {
background-color: $bg;
color: $text;
font-family: $text-font;
font-size: 16px;
font-weight: 400;
line-height: 1;
height: 100%;
width: 100%;
}
body {
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
}
header {
border-bottom: 1px solid $border-color;
padding: 1.5rem 0;
text-align: center;
width: 100%;
h1 {
display: inline-block;
margin: 0 1rem 0 0;
vertical-align: middle;
}
p {
display: inline-block;
line-height: 1.2rem;
margin: 0;
text-align: left;
vertical-align: middle;
img {
vertical-align: middle;
}
}
}
main {
width: 100%;
max-width: 600px;
margin: auto;
padding: 0 0.75rem;
form {
section {
margin-bottom: 1rem;
&.remember,
&.submit {
text-align: center;
}
&.submit {
margin-top: 2rem;
}
}
label {
font-size: 14px;
margin-bottom: 8px;
display: inline-block;
}
textarea,
input {
font-size: 1rem;
border-radius: 4px;
&[type="checkbox"] {
margin-right: 8px;
}
&[type="submit"] {
display: inline-block;
text-align: center;
background-color: $button-bg;
color: $button-text;
font-weight: 500;
font-family: inherit;
height: 2.5rem;
padding: 0 1rem;
line-height: 36px;
border: 0;
cursor: pointer;
&:hover {
background-color: $button-hover-bg;
}
}
transition: background-color 300ms ease, border 300ms ease;
}
textarea,
input[type="url"] {
color: inherit;
width: 100%;
outline: 0;
font-family: inherit;
resize: vertical;
background-color: $input-bg;
border: 1px solid color.scale($input-bg, $lightness: -25%);
padding: 10px;
&:focus,
&:active {
border: 1px solid $button-bg;
background-color: color.scale($input-bg, $lightness: +5%);
}
&::placeholder {
color: inherit;
opacity: 0.3;
}
}
}
}
footer {
border-top: 1px solid $border-color;
padding: 1rem 0;
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
flex-wrap: wrap;
section {
margin: 0.5rem 1rem;
a {
color: inherit;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

View file

@ -1 +0,0 @@
<svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2"><path d="M473.266 301.162c-6.855 35.271-61.403 73.871-124.051 81.352-32.669 3.898-64.833 7.48-99.131 5.908-56.092-2.57-100.352-13.389-100.352-13.389 0 5.46.337 10.66 1.01 15.522 7.293 55.356 54.89 58.672 99.977 60.218 45.508 1.558 86.028-11.22 86.028-11.22l1.87 41.141s-31.83 17.093-88.533 20.236c-31.268 1.719-70.092-.786-115.31-12.755C36.7 462.217 19.833 357.677 17.253 251.604c-.786-31.494-.302-61.191-.302-86.028C16.952 57.11 88.02 25.318 88.02 25.318c35.834-16.457 97.32-23.378 161.243-23.9h1.57c63.923.522 125.45 7.443 161.281 23.9 0 0 71.064 31.792 71.064 140.258 0 0 .892 80.026-9.91 135.586" fill="#3088d4" fill-rule="nonzero"/><g fill="#fff"><path d="M476.925 278.214c-4.531 1.19-9.3 1.72-14.272 1.72-15.137 0-26.834-3.956-35.088-11.868-8.256-7.915-12.386-19.439-12.386-34.576v-66.309h-22.704V141.38h22.704v-31.477h32.253v31.477h34.342c.961 7.6 1.403 15.66 1.403 24.197l-.003 1.605h-35.742v65.536c0 6.708 1.633 11.826 4.9 15.352 3.27 3.527 7.999 5.288 14.192 5.288 5.035 0 9.482-.918 13.318-2.817l-.471 5.996-2.446 21.678z"/><path d="M326.94 279.935c-13.933 0-26.492-3.012-37.672-9.033-11.182-6.02-19.91-14.404-26.19-25.155-6.276-10.75-9.417-22.922-9.417-36.51 0-13.587 3.141-25.715 9.418-36.38 6.28-10.665 15.007-19.008 26.19-25.026 11.179-6.02 23.738-9.032 37.67-9.032 14.105 0 26.747 3.011 37.927 9.032 11.182 6.018 19.91 14.361 26.19 25.026 6.276 10.665 9.417 22.793 9.417 36.38 0 13.588-3.14 25.76-9.418 36.51-6.279 10.751-15.007 19.135-26.19 25.155-11.179 6.021-23.82 9.033-37.926 9.033zm0-27.61c11.866 0 21.671-3.954 29.41-11.868 7.743-7.912 11.614-18.319 11.614-31.22 0-12.9-3.871-23.307-11.613-31.219-7.74-7.911-17.545-11.869-29.412-11.869-11.869 0-21.631 3.958-29.285 11.87-7.656 7.911-11.48 18.318-11.48 31.219 0 12.9 3.824 23.307 11.48 31.219 7.654 7.914 17.416 11.869 29.285 11.869z" fill-rule="nonzero"/><path d="M181.159 279.935c-13.933 0-26.489-3.012-37.668-9.033-11.182-6.02-19.91-14.404-26.19-25.155-6.28-10.75-9.418-22.922-9.418-36.51 0-13.587 3.139-25.715 9.418-36.38 6.28-10.665 15.008-19.008 26.19-25.026 11.18-6.02 23.735-9.032 37.668-9.032 14.105 0 26.747 3.011 37.93 9.032 11.179 6.018 19.91 14.361 26.189 25.026 6.276 10.665 9.415 22.793 9.415 36.38 0 13.588-3.139 25.76-9.415 36.51-6.28 10.751-15.01 19.135-26.19 25.155-11.182 6.021-23.824 9.033-37.93 9.033zm0-27.61c11.869 0 21.674-3.954 29.414-11.868 7.742-7.912 11.61-18.319 11.61-31.22 0-12.9-3.868-23.307-11.61-31.219-7.74-7.911-17.545-11.869-29.414-11.869-11.867 0-21.63 3.958-29.285 11.87-7.653 7.911-11.481 18.318-11.481 31.219 0 12.9 3.828 23.307 11.48 31.219 7.657 7.914 17.42 11.869 29.286 11.869z" fill-rule="nonzero"/><path d="M18.353 141.38h21.158v-31.478h32.25v31.477h36.896v25.802H71.762v65.536c0 6.708 1.635 11.826 4.902 15.352 3.268 3.527 7.998 5.288 14.192 5.288 7.222 0 13.243-1.89 18.06-5.676l9.029 22.963c-3.782 3.098-8.383 5.42-13.803 6.969-5.418 1.546-11.137 2.322-17.158 2.322-15.136 0-26.833-3.957-35.09-11.87-8.256-7.914-12.383-19.438-12.383-34.575v-66.309H16.947l.005-1.605c0-8.537.44-16.597 1.401-24.197z"/></g></svg>

Before

Width:  |  Height:  |  Size: 3.1 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 4.9 KiB

11
src/stores/i18n.ts Normal file
View file

@ -0,0 +1,11 @@
/*!
* This file is part of ShareFedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { persistentAtom } from "@nanostores/persistent";
export const $locale = persistentAtom<string | undefined>("locale");

View file

@ -0,0 +1,46 @@
/*!
* This file is part of ShareFedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { persistentAtom } from "@nanostores/persistent";
import { onMount, task } from "nanostores";
const UPDATE_INTERVAL_MS = 1000 * 60 * 60 * 24; // one day
export const $popularInstances = persistentAtom<string[]>(
"popularInstances",
[],
{
encode: JSON.stringify,
decode: JSON.parse,
},
);
export const $lastFetched = persistentAtom<Date>(
"popularInstancesLastFetched",
new Date(0),
{
encode: (date) => date.toISOString(),
decode: (encoded) => new Date(encoded),
},
);
onMount($popularInstances, () => {
task(async () => {
if (Date.now() - $lastFetched.get().getTime() < UPDATE_INTERVAL_MS) {
return;
}
try {
const response = await fetch("/api/instances");
$popularInstances.set(await response.json());
$lastFetched.set(new Date());
} catch (error) {
console.error("Could not fetch popular instances:", error);
}
});
});

View file

@ -0,0 +1,48 @@
/*!
* This file is part of ShareFedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { persistentAtom } from "@nanostores/persistent";
import { getUrlDomain } from "@lib/url";
import { action, onMount } from "nanostores";
const OLD_LOCAL_STORAGE_KEY = "recentInstances";
const LOCAL_STORAGE_KEY = "savedInstances";
const CAPACITY = 5;
export const $savedInstances = persistentAtom<Set<string>>(
LOCAL_STORAGE_KEY,
new Set(),
{
encode: (set) => JSON.stringify([...set]),
decode: (value) => new Set(JSON.parse(value)),
},
);
onMount($savedInstances, () => {
// XXX: The conversion to a domain need to be done to support legacy
// users, who may have full URLs in their Storage
const oldItem = localStorage.getItem(OLD_LOCAL_STORAGE_KEY);
if (!oldItem) {
return;
}
$savedInstances.set(
new Set(
JSON.parse(oldItem).map((instanceUrl: string) =>
getUrlDomain(instanceUrl),
),
),
);
localStorage.removeItem(OLD_LOCAL_STORAGE_KEY);
});
export const save = action($savedInstances, "save", (store, instance) => {
store.set(
new Set([getUrlDomain(instance), ...store.get()].slice(0, CAPACITY)),
);
});

183
src/styles/main.scss Normal file
View file

@ -0,0 +1,183 @@
/*!
* This file is part of ShareFedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
@use "sass:math";
*,
*::before,
*::after {
box-sizing: border-box;
}
:root {
--s2f-accent-color: #40665c;
--s2f-accent-color-light: #5d8379;
--s2f-accent-color-contrast: #005e4e;
--s2f-error-color: #a12f2d;
--s2f-border-color: #ccc;
--s2f-border-width: 1px;
--s2f-input-group-bg-color: #eee;
--s2f-input-bg-color: #fff;
--s2f-input-text-color: #000;
--s2f-button-text-color: #fff;
color-scheme: light dark;
accent-color: var(--s2f-accent-color);
font-family: "Helvetica Neue", Helvetica, FreeSans, "Nimbus Sans L", Inter,
Arial, system-ui, sans-serif;
font-size: 16px;
}
html {
line-height: 1.5;
}
body {
max-width: 60em;
margin: 0 auto;
display: flex;
flex-flow: row wrap;
> * {
flex-shrink: 0;
width: 100%;
max-width: 100%;
}
}
header {
padding: 1rem;
display: flex;
align-items: center;
justify-content: space-between;
> div {
text-align: right;
}
}
main {
margin-bottom: 2rem;
}
main,
aside {
padding: 0 1rem;
}
hr {
height: 0;
color: inherit;
border-color: var(--s2f-border-color);
border-width: 0.5px;
}
details {
font-size: smaller;
}
summary {
font-weight: bolder;
}
a {
color: var(--s2f-accent-color-contrast);
}
b,
strong {
font-weight: bolder;
}
label {
display: block;
}
input,
textarea {
font-family: inherit;
font-size: 100%;
line-height: 1.15;
margin: 0;
padding: 0.5rem;
border-radius: 4px;
}
textarea {
resize: vertical;
}
input[type="text"],
textarea {
width: 100%;
color: var(--s2f-input-text-color);
background-color: var(--s2f-input-bg-color);
border: var(--s2f-border-width) solid var(--s2f-border-color);
}
input[type="checkbox"],
input[type="radio"] {
vertical-align: middle;
}
input[type="submit"] {
background-color: var(--s2f-accent-color);
color: var(--s2f-button-text-color);
font-weight: bolder;
height: 2.5rem;
padding: 0.5rem 1.5rem;
border: 0;
cursor: pointer;
appearance: button;
&:hover {
background-color: var(--s2f-accent-color-light);
}
}
@media (prefers-color-scheme: dark) {
:root {
--s2f-accent-color: #43776a;
--s2f-accent-color-light: #619587;
--s2f-accent-color-contrast: #a8f7e2;
--s2f-border-color: #333;
--s2f-input-group-bg-color: #111;
}
}
@media screen and (width >= 768px) {
main,
aside {
flex: 0 0 auto;
}
main {
width: math.div(200%, 3);
}
aside {
width: math.div(100%, 3);
}
}
[aria-invalid="true"],
[aria-errormessage] {
--s2f-input-text-color: var(--s2f-error-color);
--s2f-border-color: var(--s2f-error-color);
accent-color: var(--s2f-error-color);
}
p.error {
color: var(--s2f-error-color);
margin: 0 0 1rem;
}
.mt1r {
margin-top: 1rem !important;
}

22
tsconfig.json Normal file
View file

@ -0,0 +1,22 @@
// This TypeScript config is part of ShareFedi
// https://github.com/kytta/share2fedi
//
// SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
// SPDX-License-Identifier: CC0-1.0
{
"extends": "astro/tsconfigs/strictest",
"compilerOptions": {
"ignoreDeprecations": "5.0",
"baseUrl": ".",
"resolveJsonModule": true,
"paths": {
"@components/*": ["src/components/*"],
"@i18n/*": ["src/i18n/*"],
"@layouts/*": ["src/layouts/*"],
"@pages/*": ["src/pages/*"],
"@lib/*": ["src/lib/*"],
"@stores/*": ["src/stores/*"],
"@styles/*": ["src/styles/*"]
}
}
}

View file

@ -1,7 +1,7 @@
{ {
"framework": null, "framework": "astro",
"installCommand": "pnpm install", "installCommand": "pnpm install",
"buildCommand": "pnpm run build", "buildCommand": "pnpm run build",
"outputDirectory": "public", "outputDirectory": "dist",
"devCommand": "pnpm run dev" "devCommand": "pnpm run dev"
} }