mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-01 01:59:56 +00:00
Add torrent help (#2650)
* Updating translations. * Adding a link to view all a user's moderation history from an item. - Also making moderation history strings more detailed. * Fix. * Adding admin view moderation history to profile page. * Adding a torrent help message. * Updating translations. * Updating translations.
This commit is contained in:
parent
999b083545
commit
8d5e7de18e
4 changed files with 58 additions and 16 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 1f4e378f2e18d843aec1e421b99a69a76ce633b7
|
Subproject commit aa39a764aec120d781325dc8b55732aafffe0ac7
|
|
@ -7,6 +7,7 @@ import { canAdmin, canMod } from "@utils/roles";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { Component, linkEvent } from "inferno";
|
import { Component, linkEvent } from "inferno";
|
||||||
import { Link } from "inferno-router";
|
import { Link } from "inferno-router";
|
||||||
|
import { T } from "inferno-i18next-dess";
|
||||||
import {
|
import {
|
||||||
AddAdmin,
|
AddAdmin,
|
||||||
AddModToCommunity,
|
AddModToCommunity,
|
||||||
|
@ -33,7 +34,7 @@ import {
|
||||||
SavePost,
|
SavePost,
|
||||||
TransferCommunity,
|
TransferCommunity,
|
||||||
} from "lemmy-js-client";
|
} from "lemmy-js-client";
|
||||||
import { relTags } from "../../config";
|
import { relTags, torrentHelpUrl } from "../../config";
|
||||||
import { IsoDataOptionalSite, VoteContentType } from "../../interfaces";
|
import { IsoDataOptionalSite, VoteContentType } from "../../interfaces";
|
||||||
import { mdToHtml, mdToHtmlInline } from "../../markdown";
|
import { mdToHtml, mdToHtmlInline } from "../../markdown";
|
||||||
import { I18NextService, UserService } from "../../services";
|
import { I18NextService, UserService } from "../../services";
|
||||||
|
@ -52,6 +53,9 @@ import PostActionDropdown from "../common/content-actions/post-action-dropdown";
|
||||||
import { CrossPostParams } from "@utils/types";
|
import { CrossPostParams } from "@utils/types";
|
||||||
import { RequestState } from "../../services/HttpService";
|
import { RequestState } from "../../services/HttpService";
|
||||||
import { toast } from "../../toast";
|
import { toast } from "../../toast";
|
||||||
|
import isMagnetLink, {
|
||||||
|
extractMagnetLinkDownloadName,
|
||||||
|
} from "@utils/media/is-magnet-link";
|
||||||
|
|
||||||
type PostListingState = {
|
type PostListingState = {
|
||||||
showEdit: boolean;
|
showEdit: boolean;
|
||||||
|
@ -176,6 +180,10 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
<>
|
<>
|
||||||
{this.listing()}
|
{this.listing()}
|
||||||
{this.state.imageExpanded && !this.props.hideImage && this.img}
|
{this.state.imageExpanded && !this.props.hideImage && this.img}
|
||||||
|
{this.showBody &&
|
||||||
|
post.url &&
|
||||||
|
isMagnetLink(post.url) &&
|
||||||
|
this.torrentHelp()}
|
||||||
{this.showBody && post.url && post.embed_title && (
|
{this.showBody && post.url && post.embed_title && (
|
||||||
<MetadataCard post={post} />
|
<MetadataCard post={post} />
|
||||||
)}
|
)}
|
||||||
|
@ -217,6 +225,19 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
torrentHelp() {
|
||||||
|
return (
|
||||||
|
<div className="alert alert-info small my-2" role="alert">
|
||||||
|
<Icon icon="info" classes="icon-inline me-2" />
|
||||||
|
<T parent="span" i18nKey="torrent_help">
|
||||||
|
#
|
||||||
|
<a className="alert-link" rel={relTags} href={torrentHelpUrl}>
|
||||||
|
#
|
||||||
|
</a>
|
||||||
|
</T>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
get img() {
|
get img() {
|
||||||
const { post } = this.postView;
|
const { post } = this.postView;
|
||||||
const { url } = post;
|
const { url } = post;
|
||||||
|
@ -542,20 +563,31 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
const post = this.postView.post;
|
const post = this.postView.post;
|
||||||
const url = post.url;
|
const url = post.url;
|
||||||
|
|
||||||
return (
|
if (url) {
|
||||||
<p className="small m-0">
|
// If its a torrent link, extract the download name
|
||||||
{url && !(hostname(url) === getExternalHost()) && (
|
const linkName = isMagnetLink(url)
|
||||||
<a
|
? extractMagnetLinkDownloadName(url)
|
||||||
className="fst-italic link-dark link-opacity-75 link-opacity-100-hover"
|
: !(hostname(url) === getExternalHost())
|
||||||
href={url}
|
? hostname(url)
|
||||||
title={url}
|
: null;
|
||||||
rel={relTags}
|
|
||||||
>
|
if (linkName) {
|
||||||
{hostname(url)}
|
return (
|
||||||
</a>
|
<p className="small m-0">
|
||||||
)}
|
{url && !(hostname(url) === getExternalHost()) && (
|
||||||
</p>
|
<a
|
||||||
);
|
className="fst-italic link-dark link-opacity-75 link-opacity-100-hover"
|
||||||
|
href={url}
|
||||||
|
title={url}
|
||||||
|
rel={relTags}
|
||||||
|
>
|
||||||
|
{linkName}
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
duplicatesLine() {
|
duplicatesLine() {
|
||||||
|
|
|
@ -9,6 +9,7 @@ export const donateLemmyUrl = `${joinLemmyUrl}/donate`;
|
||||||
export const docsUrl = `${joinLemmyUrl}/docs/en/index.html`;
|
export const docsUrl = `${joinLemmyUrl}/docs/en/index.html`;
|
||||||
export const helpGuideUrl = `${joinLemmyUrl}/docs/en/users/01-getting-started.html`; // TODO find a way to redirect to the non-en folder
|
export const helpGuideUrl = `${joinLemmyUrl}/docs/en/users/01-getting-started.html`; // TODO find a way to redirect to the non-en folder
|
||||||
export const markdownHelpUrl = `${joinLemmyUrl}/docs/en/users/02-media.html`;
|
export const markdownHelpUrl = `${joinLemmyUrl}/docs/en/users/02-media.html`;
|
||||||
|
export const torrentHelpUrl = `${markdownHelpUrl}#torrents`;
|
||||||
export const sortingHelpUrl = `${joinLemmyUrl}/docs/en/users/03-votes-and-ranking.html`;
|
export const sortingHelpUrl = `${joinLemmyUrl}/docs/en/users/03-votes-and-ranking.html`;
|
||||||
export const archiveTodayUrl = "https://archive.today";
|
export const archiveTodayUrl = "https://archive.today";
|
||||||
export const ghostArchiveUrl = "https://ghostarchive.org";
|
export const ghostArchiveUrl = "https://ghostarchive.org";
|
||||||
|
|
9
src/shared/utils/media/is-magnet-link.ts
Normal file
9
src/shared/utils/media/is-magnet-link.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
const magnetLinkRegex = /^magnet:\?xt=urn:btih:[0-9a-fA-F]{40,}.*$/;
|
||||||
|
|
||||||
|
export default function isMagnetLink(url: string) {
|
||||||
|
return magnetLinkRegex.test(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function extractMagnetLinkDownloadName(url: string) {
|
||||||
|
return new URLSearchParams(url).get("dn");
|
||||||
|
}
|
Loading…
Reference in a new issue