{this.posts()} diff --git a/src/shared/components/modlog.tsx b/src/shared/components/modlog.tsx index ba0fe8d..86e93be 100644 --- a/src/shared/components/modlog.tsx +++ b/src/shared/components/modlog.tsx @@ -1,5 +1,4 @@ import { Component, linkEvent } from 'inferno'; -import { Helmet } from 'inferno-helmet'; import { Link } from 'inferno-router'; import { Subscription } from 'rxjs'; import { @@ -30,6 +29,7 @@ import { lemmyHttp, } from '../utils'; import { MomentTime } from './moment-time'; +import { HtmlTags } from './html-tags'; import moment from 'moment'; import { i18n } from '../i18next'; @@ -353,17 +353,16 @@ export class Modlog extends Component { } get documentTitle(): string { - if (this.state.site) { - return `Modlog - ${this.state.site.name}`; - } else { - return 'Lemmy'; - } + return `Modlog - ${this.state.site.name}`; } render() { return (
- + {this.state.loading ? (
diff --git a/src/shared/components/password_change.tsx b/src/shared/components/password_change.tsx index def7bb5..1725906 100644 --- a/src/shared/components/password_change.tsx +++ b/src/shared/components/password_change.tsx @@ -1,5 +1,4 @@ import { Component, linkEvent } from 'inferno'; -import { Helmet } from 'inferno-helmet'; import { Subscription } from 'rxjs'; import { UserOperation, @@ -18,6 +17,7 @@ import { wsSubscribe, } from '../utils'; import { i18n } from '../i18next'; +import { HtmlTags } from './html-tags'; interface State { passwordChangeForm: PasswordChangeForm; @@ -61,7 +61,10 @@ export class PasswordChange extends Component { render() { return (
- +
{i18n.t('password_change')}
diff --git a/src/shared/components/post-listing.tsx b/src/shared/components/post-listing.tsx index b899e75..732d573 100644 --- a/src/shared/components/post-listing.tsx +++ b/src/shared/components/post-listing.tsx @@ -38,6 +38,7 @@ import { previewLines, } from '../utils'; import { i18n } from '../i18next'; +import { externalHost } from '../env'; interface PostListingState { showEdit: boolean; @@ -309,7 +310,7 @@ export class PostListing extends Component { )}
  • •
  • - {post.url && !(hostname(post.url) == window.location.hostname) && ( + {post.url && !(hostname(post.url) == externalHost) && ( <>
  • { {post.name} )} - {(isImage(post.url) || this.props.post.thumbnail_url) && ( - <> - {!this.state.imageExpanded ? ( + {(isImage(post.url) || this.props.post.thumbnail_url) && + (!this.state.imageExpanded ? ( + + + + + + ) : ( + - + - ) : ( - +
    - - - + -
    - - - -
    - - )} - - )} +
    +
    + ))} {post.removed && ( {i18n.t('removed')} diff --git a/src/shared/components/post.tsx b/src/shared/components/post.tsx index e3ff264..6f1bf6d 100644 --- a/src/shared/components/post.tsx +++ b/src/shared/components/post.tsx @@ -1,5 +1,5 @@ import { Component, linkEvent } from 'inferno'; -import { Helmet } from 'inferno-helmet'; +import { HtmlTags } from './html-tags'; import { Subscription } from 'rxjs'; import { UserOperation, @@ -36,7 +36,6 @@ import { createPostLikeRes, commentsToFlatNodes, setupTippy, - favIconUrl, setIsoData, getIdFromProps, getCommentIdFromProps, @@ -44,6 +43,8 @@ import { setAuth, lemmyHttp, isBrowser, + previewLines, + isImage, } from '../utils'; import { PostListing } from './post-listing'; import { Sidebar } from './sidebar'; @@ -148,7 +149,7 @@ export class Post extends Component { // Necessary if you are on a post and you click another post (same route) if (_lastProps.location.pathname !== _lastProps.history.location.pathname) { - // Couldnt get a refresh working. This does for now. + // TODO Couldnt get a refresh working. This does for now. location.reload(); // let currentId = this.props.match.params.id; @@ -191,30 +192,29 @@ export class Post extends Component { } get documentTitle(): string { - if (this.state.postRes) { - return `${this.state.postRes.post.name} - ${this.state.siteRes.site.name}`; - } else { - return 'Lemmy'; - } + return `${this.state.postRes.post.name} - ${this.state.siteRes.site.name}`; } - get favIcon(): string { - return this.state.siteRes.site.icon - ? this.state.siteRes.site.icon - : favIconUrl; + get imageTag(): string { + return ( + this.state.postRes.post.thumbnail_url || + (this.state.postRes.post.url + ? isImage(this.state.postRes.post.url) + ? this.state.postRes.post.url + : undefined + : undefined) + ); + } + + get descriptionTag(): string { + return this.state.postRes.post.body + ? previewLines(this.state.postRes.post.body) + : undefined; } render() { return (
    - - - {this.state.loading ? (
    @@ -224,6 +224,12 @@ export class Post extends Component { ) : (
    + { } get documentTitle(): string { - if (this.state.site.name) { - if (this.state.q) { - return `${i18n.t('search')} - ${this.state.q} - ${ - this.state.site.name - }`; - } else { - return `${i18n.t('search')} - ${this.state.site.name}`; - } + if (this.state.q) { + return `${i18n.t('search')} - ${this.state.q} - ${this.state.site.name}`; } else { - return 'Lemmy'; + return `${i18n.t('search')} - ${this.state.site.name}`; } } render() { return (
    - +
    {i18n.t('search')}
    {this.selects()} {this.searchForm()} diff --git a/src/shared/components/sponsors.tsx b/src/shared/components/sponsors.tsx index 9e3da9d..0e7156c 100644 --- a/src/shared/components/sponsors.tsx +++ b/src/shared/components/sponsors.tsx @@ -1,10 +1,10 @@ import { Component } from 'inferno'; -import { Helmet } from 'inferno-helmet'; import { Site } from 'lemmy-js-client'; import { i18n } from '../i18next'; import { T } from 'inferno-i18next'; import { repoUrl, isBrowser } from '../utils'; import { IsoData } from 'shared/interfaces'; +import { HtmlTags } from './html-tags'; interface SilverUser { name: string; @@ -74,7 +74,10 @@ export class Sponsors extends Component { render() { return (
    - + {this.topMessage()}
    {this.sponsors()} diff --git a/src/shared/components/user.tsx b/src/shared/components/user.tsx index db1586d..9febcd8 100644 --- a/src/shared/components/user.tsx +++ b/src/shared/components/user.tsx @@ -1,5 +1,4 @@ import { Component, linkEvent } from 'inferno'; -import { Helmet } from 'inferno-helmet'; import { Link } from 'inferno-router'; import { Subscription } from 'rxjs'; import { @@ -33,7 +32,6 @@ import { getLanguage, mdToHtml, elementUrl, - favIconUrl, setIsoData, getIdFromProps, getUsernameFromProps, @@ -44,8 +42,10 @@ import { createPostLikeFindRes, setAuth, lemmyHttp, + previewLines, } from '../utils'; import { UserListing } from './user-listing'; +import { HtmlTags } from './html-tags'; import { SortSelect } from './sort-select'; import { ListingTypeSelect } from './listing-type-select'; import { MomentTime } from './moment-time'; @@ -250,30 +250,18 @@ export class User extends Component { } get documentTitle(): string { - if (this.state.siteRes.site.name) { - return `@${this.state.userName} - ${this.state.siteRes.site.name}`; - } else { - return 'Lemmy'; - } + return `@${this.state.userName} - ${this.state.siteRes.site.name}`; } - get favIcon(): string { - return this.state.siteRes.site.icon - ? this.state.siteRes.site.icon - : favIconUrl; + get bioTag(): string { + return this.state.userRes.user.bio + ? previewLines(this.state.userRes.user.bio) + : undefined; } render() { return (
    - - - {this.state.loading ? (
    @@ -284,6 +272,12 @@ export class User extends Component {
    <> + {this.userInfo()}
    diff --git a/src/shared/env.ts b/src/shared/env.ts index 3d5533d..7347a19 100644 --- a/src/shared/env.ts +++ b/src/shared/env.ts @@ -1,15 +1,46 @@ import { isBrowser } from './utils'; -const nodeHostname = process.env.LEMMY_HOST || 'localhost'; // used for local dev -const host = isBrowser() ? window.location.hostname : nodeHostname; +const testHost = 'localhost:8536'; + +const internalHost = process.env.LEMMY_INTERNAL_HOST || testHost; // used for local dev +export const externalHost = isBrowser() + ? `${window.location.hostname}:${ + window.location.port == '1234' || window.location.port == '1235' + ? 8536 + : window.location.port + }` + : process.env.LEMMY_EXTERNAL_HOST || testHost; + +// ? window.location.port == '1234' || window.location.port == '1235' const secure = isBrowser() && window.location.protocol == 'https:' ? 's' : ''; -const port = isBrowser() - ? window.location.port == '1234' || window.location.port == '1235' - ? 8536 - : window.location.port - : 8536; -const endpoint = `${host}:${port}`; - -export const wsUri = `ws${secure}://${endpoint}/api/v1/ws`; -export const httpUri = `http${secure}://${endpoint}/api/v1`; -export const pictrsUri = `http${secure}://${endpoint}/pictrs/image`; + +const host = isBrowser() ? externalHost : internalHost; + +const httpBase = `http${secure}://${host}`; +export const wsUri = `ws${secure}://${host}/api/v1/ws`; +export const httpUri = `${httpBase}/api/v1`; +const httpExternalUri = `http${secure}://${externalHost}`; +export const pictrsUri = `${httpBase}/pictrs/image`; + +console.log(`Internal host: ${internalHost}`); +console.log(`External host: ${externalHost}`); + +export function httpExternalPath(path: string) { + return `${httpExternalUri}${path}`; +} + +// export const httpUri = `http${secure}://${endpoint}/api/v1`; +// export const pictrsUri = `http${secure}://${endpoint}/pictrs/image`; + +// const host = isBrowser() ? window.location.hostname : localHostname; +// const secure = isBrowser() && window.location.protocol == 'https:' ? 's' : ''; +// const port = isBrowser() +// ? window.location.port == '1234' || window.location.port == '1235' +// ? 8536 +// : window.location.port +// : 8536; +// const endpoint = `${host}:${port}`; +// +// export const wsUri = `ws${secure}://${endpoint}/api/v1/ws`; +// export const httpUri = `http${secure}://${endpoint}/api/v1`; +// export const pictrsUri = `http${secure}://${endpoint}/pictrs/image`; diff --git a/src/shared/utils.ts b/src/shared/utils.ts index 0a5d6ea..79d52ad 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -271,7 +271,6 @@ export function isVideo(url: string) { // TODO this broke export function validURL(str: string) { - console.log(str); // try { return !!new URL(str); // } catch { @@ -439,8 +438,6 @@ export function getMomentLanguage(): string { export function setTheme(theme: string, forceReload: boolean = false) { if (isBrowser() && (theme !== 'darkly' || forceReload)) { - console.log(`setting theme ${theme}`); - // Unload all the other themes for (var i = 0; i < themes.length; i++) { let styleSheet = document.getElementById(themes[i]); @@ -1078,11 +1075,7 @@ export function previewLines( export function hostname(url: string): string { let cUrl = new URL(url); - // TODO - return `${cUrl.hostname}:${cUrl.port}`; - // return window.location.port - // ? `${cUrl.hostname}:${cUrl.port}` - // : `${cUrl.hostname}`; + return cUrl.port ? `${cUrl.hostname}:${cUrl.port}` : `${cUrl.hostname}`; } function canUseWebP() { -- 2.44.1