Update code style
This commit is contained in:
parent
65bef1053f
commit
7f107b408d
8 changed files with 99 additions and 33 deletions
|
@ -4,6 +4,7 @@ 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
|
||||||
|
|
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
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.1.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]
|
## [v3 (unreleased)][Unreleased]
|
||||||
|
|
||||||
|
@ -153,7 +155,8 @@ as to indicate that sharing to other federated networks is now possible.
|
||||||
|
|
||||||
### 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
|
||||||
|
|
||||||
|
@ -167,7 +170,8 @@ as to indicate that sharing to other federated networks is now possible.
|
||||||
|
|
||||||
### 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
|
||||||
|
|
||||||
|
@ -236,4 +240,5 @@ Initial release of the site
|
||||||
[1.1.2]: https://github.com/kytta/share2fedi/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://github.com/kytta/share2fedi/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://github.com/kytta/share2fedi/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://github.com/kytta/share2fedi/compare/e85aa15400bcdbcccf655d331f72df8304744b85...v1.0.0
|
[1.0.0]:
|
||||||
|
https://github.com/kytta/share2fedi/compare/e85aa15400bcdbcccf655d331f72df8304744b85...v1.0.0
|
||||||
|
|
29
README.md
29
README.md
|
@ -2,9 +2,14 @@
|
||||||
|
|
||||||
> Instance-agnostic share page for the Fediverse.
|
> Instance-agnostic share page for the Fediverse.
|
||||||
|
|
||||||
**[Share₂Fedi]** allows you to share stuff on Mastodon, GoToSocial, Pleroma, and other federated social networks, instance-agnostic. Just type in the post text and the instance URL, and click ‘Post!’
|
**[Share₂Fedi]** allows you to share stuff on Mastodon, GoToSocial, Pleroma, 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` URL parameter. This can be used to build custom share buttons for the federated social networks:
|
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` URL
|
||||||
|
parameter. This can be used to build custom share buttons for the federated
|
||||||
|
social networks:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<a
|
<a
|
||||||
|
@ -14,14 +19,15 @@ Or, open this page with the prefilled `text` URL parameter—it will be automati
|
||||||
</a>
|
</a>
|
||||||
```
|
```
|
||||||
|
|
||||||
The instance URL can be saved in your `localStorage` to be automatically appended if used later—handy!
|
The instance URL can be saved in your `localStorage` to be automatically
|
||||||
|
appended if used later—handy!
|
||||||
|
|
||||||
## Hosting
|
## Hosting
|
||||||
|
|
||||||
### One-click Vercel deploy
|
### One-click Vercel deploy
|
||||||
|
|
||||||
**Share₂Fedi** is designed to run on [Vercel](https://vercel.com/).
|
**Share₂Fedi** is designed to run on [Vercel](https://vercel.com/). To deploy it
|
||||||
To deploy it yourself (it's free!), you can use the following button:
|
yourself (it's free!), you can use the following button:
|
||||||
|
|
||||||
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fkytta%2Fshare2fedi)
|
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fkytta%2Fshare2fedi)
|
||||||
|
|
||||||
|
@ -55,13 +61,14 @@ Self-hosting **Share₂Fedi** outside of Vercel requires some extra setup:
|
||||||
pm2 start api/share.js --watch --ignore-watch="node_modules"
|
pm2 start api/share.js --watch --ignore-watch="node_modules"
|
||||||
```
|
```
|
||||||
|
|
||||||
> You can find a summary for pm2 at: https://pm2.keymetrics.io/docs/usage/quick-start/
|
> You can find a summary for pm2 at:
|
||||||
|
> https://pm2.keymetrics.io/docs/usage/quick-start/
|
||||||
|
|
||||||
4. Set up a web server
|
4. Set up a web server
|
||||||
|
|
||||||
Basically, you need to run a server that would proxy the requests to `/api/share`.
|
Basically, you need to run a server that would proxy the requests to
|
||||||
to the Node.js server you started. Here's how to achieve this in various HTTP
|
`/api/share`. to the Node.js server you started. Here's how to achieve this
|
||||||
servers:
|
in various HTTP servers:
|
||||||
|
|
||||||
1. Apache
|
1. Apache
|
||||||
|
|
||||||
|
@ -95,8 +102,8 @@ Self-hosting **Share₂Fedi** outside of Vercel requires some extra setup:
|
||||||
|
|
||||||
## 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 **Share₂Fedi** under the hood!
|
share buttons) uses **Share₂Fedi** under the hood!
|
||||||
|
|
||||||
## Licence
|
## Licence
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ const queryUrl = (url, service) => {
|
||||||
const detectService = async (instanceURL) => {
|
const detectService = async (instanceURL) => {
|
||||||
const checkPromises = Object.entries(pathsMap).map(
|
const checkPromises = Object.entries(pathsMap).map(
|
||||||
([service, { checkUrl }]) =>
|
([service, { checkUrl }]) =>
|
||||||
queryUrl(new URL(checkUrl, instanceURL), service)
|
queryUrl(new URL(checkUrl, instanceURL), service),
|
||||||
);
|
);
|
||||||
|
|
||||||
return await Promise.any(checkPromises);
|
return await Promise.any(checkPromises);
|
||||||
|
|
70
index.html
70
index.html
|
@ -24,7 +24,10 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta
|
||||||
|
name="viewport"
|
||||||
|
content="width=device-width, initial-scale=1.0"
|
||||||
|
/>
|
||||||
<title>
|
<title>
|
||||||
Share₂Fedi — an instance-agnostic share page for the Fediverse
|
Share₂Fedi — an instance-agnostic share page for the Fediverse
|
||||||
</title>
|
</title>
|
||||||
|
@ -32,22 +35,58 @@
|
||||||
name="description"
|
name="description"
|
||||||
content="Share₂Fedi is a share page for Mastodon and GNU Social. Type in your post text and the instance URL and click ‘Publish!’"
|
content="Share₂Fedi is a share page for Mastodon and GNU Social. Type in your post text and the instance URL and click ‘Publish!’"
|
||||||
/>
|
/>
|
||||||
<link rel="canonical" href="https://s2f.kytta.dev/" />
|
<link
|
||||||
|
rel="canonical"
|
||||||
|
href="https://s2f.kytta.dev/"
|
||||||
|
/>
|
||||||
|
|
||||||
<script type="module" src="/lib/main.js" async defer></script>
|
<script
|
||||||
<script type="module" src="/lib/count.js" async defer></script>
|
type="module"
|
||||||
|
src="/lib/main.js"
|
||||||
|
async
|
||||||
|
defer
|
||||||
|
></script>
|
||||||
|
<script
|
||||||
|
type="module"
|
||||||
|
src="/lib/count.js"
|
||||||
|
async
|
||||||
|
defer
|
||||||
|
></script>
|
||||||
|
|
||||||
<link rel="icon" href="/favicon.ico" sizes="any" />
|
<link
|
||||||
<link rel="icon" href="/icon.svg" type="image/svg+xml" />
|
rel="icon"
|
||||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
href="/favicon.ico"
|
||||||
<link rel="manifest" href="/manifest.webmanifest" />
|
sizes="any"
|
||||||
|
/>
|
||||||
|
<link
|
||||||
|
rel="icon"
|
||||||
|
href="/icon.svg"
|
||||||
|
type="image/svg+xml"
|
||||||
|
/>
|
||||||
|
<link
|
||||||
|
rel="apple-touch-icon"
|
||||||
|
href="/apple-touch-icon.png"
|
||||||
|
/>
|
||||||
|
<link
|
||||||
|
rel="manifest"
|
||||||
|
href="/manifest.webmanifest"
|
||||||
|
/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<img src="/logo.svg" alt="Share2Fedi" width="195" height="60" />
|
<img
|
||||||
|
src="/logo.svg"
|
||||||
|
alt="Share2Fedi"
|
||||||
|
width="195"
|
||||||
|
height="60"
|
||||||
|
/>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<form id="js-s2f-form" action="/api/share" method="POST">
|
<form
|
||||||
|
id="js-s2f-form"
|
||||||
|
action="/api/share"
|
||||||
|
method="POST"
|
||||||
|
>
|
||||||
<label>
|
<label>
|
||||||
Post text
|
Post text
|
||||||
<textarea
|
<textarea
|
||||||
|
@ -73,11 +112,18 @@
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label for="remember">
|
<label for="remember">
|
||||||
<input type="checkbox" id="remember" name="remember" />
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="remember"
|
||||||
|
name="remember"
|
||||||
|
/>
|
||||||
Remember my instance on this device
|
Remember my instance on this device
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<input type="submit" value="Publish" />
|
<input
|
||||||
|
type="submit"
|
||||||
|
value="Publish"
|
||||||
|
/>
|
||||||
</form>
|
</form>
|
||||||
</main>
|
</main>
|
||||||
<aside>
|
<aside>
|
||||||
|
|
|
@ -47,13 +47,13 @@ if (
|
||||||
window.screen.width,
|
window.screen.width,
|
||||||
window.screen.height,
|
window.screen.height,
|
||||||
window.devicePixelRatio || 1,
|
window.devicePixelRatio || 1,
|
||||||
].join(",")
|
].join(","),
|
||||||
);
|
);
|
||||||
|
|
||||||
const random = encodeURIComponent(Math.random().toString(36).slice(2));
|
const random = encodeURIComponent(Math.random().toString(36).slice(2));
|
||||||
|
|
||||||
navigator.sendBeacon(
|
navigator.sendBeacon(
|
||||||
`https://share2fedi.goatcounter.com/count?p=%2F&s=${screen}&b=0&rnd=${random}`
|
`https://share2fedi.goatcounter.com/count?p=%2F&s=${screen}&b=0&rnd=${random}`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ function onLoadInstancesSuccess() {
|
||||||
|
|
||||||
const currentInstance = $instance.value;
|
const currentInstance = $instance.value;
|
||||||
const instanceDomains = JSON.parse(this.responseText).map(
|
const instanceDomains = JSON.parse(this.responseText).map(
|
||||||
(index) => index.domain
|
(index) => index.domain,
|
||||||
);
|
);
|
||||||
if (currentInstance && !instanceDomains.includes(currentInstance)) {
|
if (currentInstance && !instanceDomains.includes(currentInstance)) {
|
||||||
instanceDomains.push(currentInstance);
|
instanceDomains.push(currentInstance);
|
||||||
|
@ -107,7 +107,7 @@ function rememberInstance(instance) {
|
||||||
|
|
||||||
window.localStorage.setItem(
|
window.localStorage.setItem(
|
||||||
LOCAL_STORAGE_KEY,
|
LOCAL_STORAGE_KEY,
|
||||||
JSON.stringify(recentInstances)
|
JSON.stringify(recentInstances),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ for (const URLParameter of URLParameters) {
|
||||||
const URLParameterPair = URLParameter.split("=");
|
const URLParameterPair = URLParameter.split("=");
|
||||||
if (URLParameterPair[0] === "text") {
|
if (URLParameterPair[0] === "text") {
|
||||||
document.querySelector("#text").value = decodeURIComponent(
|
document.querySelector("#text").value = decodeURIComponent(
|
||||||
URLParameterPair[1]
|
URLParameterPair[1],
|
||||||
);
|
);
|
||||||
} else if (URLParameterPair[0] === "instance") {
|
} else if (URLParameterPair[0] === "instance") {
|
||||||
prefillInstance = decodeURIComponent(URLParameterPair[1]);
|
prefillInstance = decodeURIComponent(URLParameterPair[1]);
|
||||||
|
|
|
@ -47,6 +47,13 @@
|
||||||
"postcss-csso": {}
|
"postcss-csso": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"prettier": {
|
||||||
|
"printWidth": 80,
|
||||||
|
"quoteProps": "as-needed",
|
||||||
|
"trailingComma": "all",
|
||||||
|
"proseWrap": "always",
|
||||||
|
"singleAttributePerLine": true
|
||||||
|
},
|
||||||
"stylelint": {
|
"stylelint": {
|
||||||
"extends": "stylelint-config-standard-scss"
|
"extends": "stylelint-config-standard-scss"
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue