Update code style

This commit is contained in:
Nikita Karamov 2023-03-17 14:06:30 +01:00
parent 65bef1053f
commit 7f107b408d
No known key found for this signature in database
GPG Key ID: 41D6F71EE78E77CD
8 changed files with 99 additions and 33 deletions

View File

@ -4,6 +4,7 @@ root = true
charset = utf-8
end_of_line = lf
indent_style = tab
tab_width = 2
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

View File

@ -2,7 +2,9 @@
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]
@ -153,7 +155,8 @@ as to indicate that sharing to other federated networks is now possible.
### 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
@ -167,7 +170,8 @@ as to indicate that sharing to other federated networks is now possible.
### 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
@ -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.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.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

View File

@ -2,9 +2,14 @@
> 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
<a
@ -14,14 +19,15 @@ Or, open this page with the prefilled `text` URL parameter—it will be automati
</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
### One-click Vercel deploy
**Share₂Fedi** is designed to run on [Vercel](https://vercel.com/).
To deploy it yourself (it's free!), you can use the following button:
**Share₂Fedi** is designed to run on [Vercel](https://vercel.com/). To deploy it
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)
@ -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"
```
> 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
Basically, you need to run a server that would proxy the requests to `/api/share`.
to the Node.js server you started. Here's how to achieve this in various HTTP
servers:
Basically, you need to run a server that would proxy the requests to
`/api/share`. to the Node.js server you started. Here's how to achieve this
in various HTTP servers:
1. Apache
@ -95,8 +102,8 @@ Self-hosting **Share₂Fedi** outside of Vercel requires some extra setup:
## See also
**[📯 Shareon](https://shareon.js.org)**
(lightweight, stylish, and ethical share buttons) uses **Share₂Fedi** under the hood!
**[📯 Shareon](https://shareon.js.org)** (lightweight, stylish, and ethical
share buttons) uses **Share₂Fedi** under the hood!
## Licence

View File

@ -53,7 +53,7 @@ const queryUrl = (url, service) => {
const detectService = async (instanceURL) => {
const checkPromises = Object.entries(pathsMap).map(
([service, { checkUrl }]) =>
queryUrl(new URL(checkUrl, instanceURL), service)
queryUrl(new URL(checkUrl, instanceURL), service),
);
return await Promise.any(checkPromises);

View File

@ -24,7 +24,10 @@
<html lang="en">
<head>
<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>
Share₂Fedi &mdash; an instance-agnostic share page for the Fediverse
</title>
@ -32,22 +35,58 @@
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 &lsquo;Publish!&rsquo;"
/>
<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 type="module" src="/lib/count.js" async defer></script>
<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 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" />
<link
rel="icon"
href="/favicon.ico"
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>
<body>
<header>
<img src="/logo.svg" alt="Share2Fedi" width="195" height="60" />
<img
src="/logo.svg"
alt="Share2Fedi"
width="195"
height="60"
/>
</header>
<main>
<form id="js-s2f-form" action="/api/share" method="POST">
<form
id="js-s2f-form"
action="/api/share"
method="POST"
>
<label>
Post text
<textarea
@ -73,11 +112,18 @@
</label>
<label for="remember">
<input type="checkbox" id="remember" name="remember" />
<input
type="checkbox"
id="remember"
name="remember"
/>
Remember my instance on this device
</label>
<input type="submit" value="Publish" />
<input
type="submit"
value="Publish"
/>
</form>
</main>
<aside>

View File

@ -47,13 +47,13 @@ if (
window.screen.width,
window.screen.height,
window.devicePixelRatio || 1,
].join(",")
].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}`
`https://share2fedi.goatcounter.com/count?p=%2F&s=${screen}&b=0&rnd=${random}`,
);
});
}

View File

@ -63,7 +63,7 @@ function onLoadInstancesSuccess() {
const currentInstance = $instance.value;
const instanceDomains = JSON.parse(this.responseText).map(
(index) => index.domain
(index) => index.domain,
);
if (currentInstance && !instanceDomains.includes(currentInstance)) {
instanceDomains.push(currentInstance);
@ -107,7 +107,7 @@ function rememberInstance(instance) {
window.localStorage.setItem(
LOCAL_STORAGE_KEY,
JSON.stringify(recentInstances)
JSON.stringify(recentInstances),
);
}
@ -127,7 +127,7 @@ for (const URLParameter of URLParameters) {
const URLParameterPair = URLParameter.split("=");
if (URLParameterPair[0] === "text") {
document.querySelector("#text").value = decodeURIComponent(
URLParameterPair[1]
URLParameterPair[1],
);
} else if (URLParameterPair[0] === "instance") {
prefillInstance = decodeURIComponent(URLParameterPair[1]);

View File

@ -47,6 +47,13 @@
"postcss-csso": {}
}
},
"prettier": {
"printWidth": 80,
"quoteProps": "as-needed",
"trailingComma": "all",
"proseWrap": "always",
"singleAttributePerLine": true
},
"stylelint": {
"extends": "stylelint-config-standard-scss"
}