mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-23 14:07:20 +03:00
feat(api): skip ipfs subdomain redirect
Signed-off-by: Andrew Hill <andrew@textile.io>
This commit is contained in:
parent
2fb22bdc41
commit
d5a3447dad
@ -60,3 +60,7 @@ export const theme = {
|
|||||||
pageBackground: system.foreground,
|
pageBackground: system.foreground,
|
||||||
pageText: system.black,
|
pageText: system.black,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const gateways = {
|
||||||
|
ipfs: "ipfs.slate.textile.io",
|
||||||
|
}
|
@ -50,7 +50,8 @@ const STYLES_IMAGE = css`
|
|||||||
export default class SlateMediaObject extends React.Component {
|
export default class SlateMediaObject extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const name = `${this.props.data.name}`;
|
const name = `${this.props.data.name}`;
|
||||||
const url = this.props.data.url ? this.props.data.url : `https://hub.textile.io${this.props.data.ipfs}`;
|
const cid = this.props.data.ipfs.replace('/ipfs/', '')
|
||||||
|
const url = this.props.data.url ? this.props.data.url : `https://${cid}.${Constants.gateways.ipfs}`
|
||||||
const type = this.props.data.type ? this.props.data.type : "LEGACY_NO_TYPE";
|
const type = this.props.data.type ? this.props.data.type : "LEGACY_NO_TYPE";
|
||||||
|
|
||||||
let element = <div css={STYLES_FAILURE}>No Preview</div>;
|
let element = <div css={STYLES_FAILURE}>No Preview</div>;
|
||||||
|
@ -278,7 +278,7 @@ export default class SlateMediaObjectSidebar extends React.Component {
|
|||||||
<a
|
<a
|
||||||
key="sidebar-media-open-file"
|
key="sidebar-media-open-file"
|
||||||
css={STYLES_BUTTON}
|
css={STYLES_BUTTON}
|
||||||
href={`https://hub.textile.io/ipfs/${this.props.cid}`}
|
href={`https://${this.props.cid}.${Constants.gateways.ipfs}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
>
|
>
|
||||||
Open file in a new browser tab ⭢
|
Open file in a new browser tab ⭢
|
||||||
@ -289,7 +289,7 @@ export default class SlateMediaObjectSidebar extends React.Component {
|
|||||||
<a
|
<a
|
||||||
key="sidebar-media-download-file"
|
key="sidebar-media-download-file"
|
||||||
css={STYLES_BUTTON}
|
css={STYLES_BUTTON}
|
||||||
href={`https://hub.textile.io/ipfs/${this.props.cid}`}
|
href={`https://${this.props.cid}.${Constants.gateways.ipfs}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
download={this.props.cid}
|
download={this.props.cid}
|
||||||
>
|
>
|
||||||
|
@ -8,7 +8,7 @@ import { Table } from "~/components/system/components/Table";
|
|||||||
import { StatUpload, StatDownload } from "~/components/system/components/Stat";
|
import { StatUpload, StatDownload } from "~/components/system/components/Stat";
|
||||||
|
|
||||||
let genericImg =
|
let genericImg =
|
||||||
"https://hub.textile.io/ipfs/bafybeiblly23jomdjjiq7ilth667npcfm5llqb5xfstodbbfa5pxtoek7u";
|
`https://bafybeiblly23jomdjjiq7ilth667npcfm5llqb5xfstodbbfa5pxtoek7u.${Constants.gateways.ipfs}`;
|
||||||
|
|
||||||
const STYLES_BUTTON = `
|
const STYLES_BUTTON = `
|
||||||
font-family: ${Constants.font.text};
|
font-family: ${Constants.font.text};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export const POLLING_RATE = 5000;
|
export const POLLING_RATE = 5000;
|
||||||
export const POWERGATE_HOST = "https://grpcweb.slate.textile.io";
|
export const POWERGATE_HOST = "https://grpcweb.slate.textile.io";
|
||||||
|
export const IPFS_GATEWAY_DOMAIN = "ipfs.slate.textile.io";
|
||||||
export const FILE_STORAGE_URL = "./public/static/files/";
|
export const FILE_STORAGE_URL = "./public/static/files/";
|
||||||
export const GITHUB_URL = "https://github.com/filecoin-project/slate";
|
export const GITHUB_URL = "https://github.com/filecoin-project/slate";
|
||||||
export const ANALYTICS_URL = "https://slate-stats-dev.azurewebsites.net/";
|
export const ANALYTICS_URL = "https://slate-stats-dev.azurewebsites.net/";
|
||||||
|
@ -18,7 +18,7 @@ const TEXTILE_KEY_INFO = {
|
|||||||
|
|
||||||
export const checkTextile = async () => {
|
export const checkTextile = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch("https://hub.textile.io/health", {
|
const response = await fetch("https://slate.textile.io/health", {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
@ -14,13 +14,13 @@ const friendsList = {
|
|||||||
id: 72572959238,
|
id: 72572959238,
|
||||||
user: "@martina",
|
user: "@martina",
|
||||||
img:
|
img:
|
||||||
"https://hub.textile.io/ipfs/bafybeiguo2uhd63reslbqkkgsqedgeikhtuwn5lzqpnqzluoaa3rnkfcvi",
|
"https://bafybeiguo2uhd63reslbqkkgsqedgeikhtuwn5lzqpnqzluoaa3rnkfcvi.ipfs.hub.textile.io",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2572952030,
|
id: 2572952030,
|
||||||
user: "@jim",
|
user: "@jim",
|
||||||
img:
|
img:
|
||||||
"https://hub.textile.io/ipfs/bafybeicuz5wrxonu7ud6eskrnshxb66ksg3ncu3ie776xuiydlxrkfuvmu",
|
"https://bafybeicuz5wrxonu7ud6eskrnshxb66ksg3ncu3ie776xuiydlxrkfuvmu.ipfs.hub.textile.io",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
friends: [
|
friends: [
|
||||||
@ -41,7 +41,7 @@ const friendsList = {
|
|||||||
id: 637838385993,
|
id: 637838385993,
|
||||||
user: "@aaron",
|
user: "@aaron",
|
||||||
img:
|
img:
|
||||||
"https://hub.textile.io/ipfs/bafkreicb2lookm56omsfjwuwuziwftizmdsj4oneveuqiqlu6k5hc7j5nq",
|
"https://bafkreicb2lookm56omsfjwuwuziwftizmdsj4oneveuqiqlu6k5hc7j5nq.ipfs.hub.textile.io",
|
||||||
info: {
|
info: {
|
||||||
chainHead:
|
chainHead:
|
||||||
"bafyl5q5qo5wolfxsui4ciujfucqwf6gqso4lettcjwl2tyismgol7c4tngvoono5rmytuqotye7oosfjv6g7a",
|
"bafyl5q5qo5wolfxsui4ciujfucqwf6gqso4lettcjwl2tyismgol7c4tngvoono5rmytuqotye7oosfjv6g7a",
|
||||||
@ -55,7 +55,7 @@ const friendsList = {
|
|||||||
id: 982799203032,
|
id: 982799203032,
|
||||||
user: "@colin",
|
user: "@colin",
|
||||||
img:
|
img:
|
||||||
"https://hub.textile.io/ipfs/bafybeigxb4arecl6iwsvjnwzi2lqpmmif6l2kgwptac7q3tzqmsimci2yq",
|
"https://bafybeigxb4arecl6iwsvjnwzi2lqpmmif6l2kgwptac7q3tzqmsimci2yq.ipfs.hub.textile.io",
|
||||||
info: {
|
info: {
|
||||||
chainHead:
|
chainHead:
|
||||||
"t3ual5q5qo5wolfxsui4ciujfucqwf6gqso4lettcjwl2tyismgol7c4tngvoono5rmytuqotye7oosfjv6g7a",
|
"t3ual5q5qo5wolfxsui4ciujfucqwf6gqso4lettcjwl2tyismgol7c4tngvoono5rmytuqotye7oosfjv6g7a",
|
||||||
@ -69,7 +69,7 @@ const friendsList = {
|
|||||||
id: 673883729083,
|
id: 673883729083,
|
||||||
user: "@jason",
|
user: "@jason",
|
||||||
img:
|
img:
|
||||||
"https://hub.textile.io/ipfs/bafybeicp3x3poprnrsxhnqscsiuobxejxsbcsu2t4yhte6qmcofjvjqbn4",
|
"https://bafybeicp3x3poprnrsxhnqscsiuobxejxsbcsu2t4yhte6qmcofjvjqbn4.ipfs.hub.textile.io",
|
||||||
info: {
|
info: {
|
||||||
chainHead:
|
chainHead:
|
||||||
"t3solnyrrblqlmvi6gmzewzvu62vs7uqvkl22yemzr63bcylbaaqsg44mnipepuafg7efzzx4zwcsi66jgze3q",
|
"t3solnyrrblqlmvi6gmzewzvu62vs7uqvkl22yemzr63bcylbaaqsg44mnipepuafg7efzzx4zwcsi66jgze3q",
|
||||||
@ -97,13 +97,13 @@ export default class SystemPagePeersList extends React.Component {
|
|||||||
id: 72572959238,
|
id: 72572959238,
|
||||||
user: "@martina",
|
user: "@martina",
|
||||||
img:
|
img:
|
||||||
"https://hub.textile.io/ipfs/bafybeiguo2uhd63reslbqkkgsqedgeikhtuwn5lzqpnqzluoaa3rnkfcvi",
|
"https://bafybeiguo2uhd63reslbqkkgsqedgeikhtuwn5lzqpnqzluoaa3rnkfcvi.ipfs.hub.textile.io",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2572952030,
|
id: 2572952030,
|
||||||
user: "@jim",
|
user: "@jim",
|
||||||
img:
|
img:
|
||||||
"https://hub.textile.io/ipfs/bafybeicuz5wrxonu7ud6eskrnshxb66ksg3ncu3ie776xuiydlxrkfuvmu",
|
"https://bafybeicuz5wrxonu7ud6eskrnshxb66ksg3ncu3ie776xuiydlxrkfuvmu.ipfs.hub.textile.io",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
friends: [
|
friends: [
|
||||||
@ -124,7 +124,7 @@ export default class SystemPagePeersList extends React.Component {
|
|||||||
id: 637838385993,
|
id: 637838385993,
|
||||||
user: "@aaron",
|
user: "@aaron",
|
||||||
img:
|
img:
|
||||||
"https://hub.textile.io/ipfs/bafkreicb2lookm56omsfjwuwuziwftizmdsj4oneveuqiqlu6k5hc7j5nq",
|
"https://bafkreicb2lookm56omsfjwuwuziwftizmdsj4oneveuqiqlu6k5hc7j5nq.ipfs.hub.textile.io",
|
||||||
info: {
|
info: {
|
||||||
chainHead:
|
chainHead:
|
||||||
"bafyl5q5qo5wolfxsui4ciujfucqwf6gqso4lettcjwl2tyismgol7c4tngvoono5rmytuqotye7oosfjv6g7a",
|
"bafyl5q5qo5wolfxsui4ciujfucqwf6gqso4lettcjwl2tyismgol7c4tngvoono5rmytuqotye7oosfjv6g7a",
|
||||||
@ -138,7 +138,7 @@ export default class SystemPagePeersList extends React.Component {
|
|||||||
id: 982799203032,
|
id: 982799203032,
|
||||||
user: "@colin",
|
user: "@colin",
|
||||||
img:
|
img:
|
||||||
"https://hub.textile.io/ipfs/bafybeigxb4arecl6iwsvjnwzi2lqpmmif6l2kgwptac7q3tzqmsimci2yq",
|
"https://bafybeigxb4arecl6iwsvjnwzi2lqpmmif6l2kgwptac7q3tzqmsimci2yq.ipfs.hub.textile.io",
|
||||||
info: {
|
info: {
|
||||||
chainHead:
|
chainHead:
|
||||||
"t3ual5q5qo5wolfxsui4ciujfucqwf6gqso4lettcjwl2tyismgol7c4tngvoono5rmytuqotye7oosfjv6g7a",
|
"t3ual5q5qo5wolfxsui4ciujfucqwf6gqso4lettcjwl2tyismgol7c4tngvoono5rmytuqotye7oosfjv6g7a",
|
||||||
@ -152,7 +152,7 @@ export default class SystemPagePeersList extends React.Component {
|
|||||||
id: 673883729083,
|
id: 673883729083,
|
||||||
user: "@jason",
|
user: "@jason",
|
||||||
img:
|
img:
|
||||||
"https://hub.textile.io/ipfs/bafybeicp3x3poprnrsxhnqscsiuobxejxsbcsu2t4yhte6qmcofjvjqbn4",
|
"https://bafybeicp3x3poprnrsxhnqscsiuobxejxsbcsu2t4yhte6qmcofjvjqbn4.ipfs.hub.textile.io",
|
||||||
info: {
|
info: {
|
||||||
chainHead:
|
chainHead:
|
||||||
"t3solnyrrblqlmvi6gmzewzvu62vs7uqvkl22yemzr63bcylbaaqsg44mnipepuafg7efzzx4zwcsi66jgze3q",
|
"t3solnyrrblqlmvi6gmzewzvu62vs7uqvkl22yemzr63bcylbaaqsg44mnipepuafg7efzzx4zwcsi66jgze3q",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import * as MW from "~/node_common/middleware";
|
import * as MW from "~/node_common/middleware";
|
||||||
|
import { IPFS_GATEWAY_DOMAIN } from "~/node_common/constants";
|
||||||
import * as Utilities from "~/node_common/utilities";
|
import * as Utilities from "~/node_common/utilities";
|
||||||
import * as Data from "~/node_common/data";
|
import * as Data from "~/node_common/data";
|
||||||
|
|
||||||
@ -48,6 +49,7 @@ export default async (req, res) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cid = req.body.data.ipfs.replace('/ipfs/')
|
||||||
const objects = [
|
const objects = [
|
||||||
...slate.data.objects,
|
...slate.data.objects,
|
||||||
{
|
{
|
||||||
@ -56,7 +58,7 @@ export default async (req, res) => {
|
|||||||
name: req.body.data.name,
|
name: req.body.data.name,
|
||||||
title: req.body.data.title,
|
title: req.body.data.title,
|
||||||
type: req.body.data.type,
|
type: req.body.data.type,
|
||||||
url: `https://hub.textile.io${req.body.data.ipfs}`,
|
url: `https:${cid}.${IPFS_GATEWAY_DOMAIN}`
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import * as MW from "~/node_common/middleware";
|
import * as MW from "~/node_common/middleware";
|
||||||
import * as Data from "~/node_common/data";
|
import * as Data from "~/node_common/data";
|
||||||
|
import { IPFS_GATEWAY_DOMAIN } from "~/node_common/constants";
|
||||||
import * as LibraryManager from "~/node_common/managers/library";
|
import * as LibraryManager from "~/node_common/managers/library";
|
||||||
import * as Strings from "~/common/strings";
|
import * as Strings from "~/common/strings";
|
||||||
import * as Upload from "~/node_common/upload";
|
import * as Upload from "~/node_common/upload";
|
||||||
@ -113,7 +114,8 @@ export default async (req, res) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = `https://hub.textile.io${updatedData.ipfs}`;
|
const cid = req.body.data.ipfs.replace('/ipfs/')
|
||||||
|
const url = `https:${cid}.${IPFS_GATEWAY_DOMAIN}`
|
||||||
const newSlateObjectEntity = {
|
const newSlateObjectEntity = {
|
||||||
id: updatedData.id,
|
id: updatedData.id,
|
||||||
name: updatedData.name,
|
name: updatedData.name,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import * as System from "~/components/system";
|
import * as System from "~/components/system";
|
||||||
import * as Actions from "~/common/actions";
|
import * as Actions from "~/common/actions";
|
||||||
|
import * as Constants from "~/common/Constants";
|
||||||
import * as Validations from "~/common/validations";
|
import * as Validations from "~/common/validations";
|
||||||
import * as FileUtilities from "~/common/file-utilities";
|
import * as FileUtilities from "~/common/file-utilities";
|
||||||
|
|
||||||
@ -63,9 +64,10 @@ export default class SceneEditAccount extends React.Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cid = json.data.ipfs.replace('/ipfs/', '')
|
||||||
await Actions.updateViewer({
|
await Actions.updateViewer({
|
||||||
data: {
|
data: {
|
||||||
photo: `https://hub.textile.io${json.data.ipfs}`,
|
photo: `https://${cid}.${Constants.gateways.ipfs}`,
|
||||||
body: this.state.body,
|
body: this.state.body,
|
||||||
name: this.state.name,
|
name: this.state.name,
|
||||||
},
|
},
|
||||||
|
@ -69,7 +69,8 @@ const STYLES_PATH = css`
|
|||||||
|
|
||||||
export default class SceneFile extends React.Component {
|
export default class SceneFile extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const fileURL = this.props.data.url ? this.props.data.url : `https://hub.textile.io${this.props.data.ipfs}`;
|
const cid = this.props.data.ipfs.replace('/ipfs/', '')
|
||||||
|
const fileURL = this.props.data.url ? this.props.data.url : `https://${cid}.${Constants.gateways.ipfs}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div css={STYLES_FLEX}>
|
<div css={STYLES_FLEX}>
|
||||||
|
@ -141,8 +141,9 @@ export default class SceneSlate extends React.Component {
|
|||||||
name: "slate-global-create-carousel",
|
name: "slate-global-create-carousel",
|
||||||
detail: {
|
detail: {
|
||||||
slides: state.objects.map((each) => {
|
slides: state.objects.map((each) => {
|
||||||
const cid = each.url.replace("https://hub.textile.io/ipfs/", "");
|
// NOTE
|
||||||
|
// regex here performs https://{cid}.ipfs.hub.textile.io => [https://{cid}, {cid}]
|
||||||
|
let cid = each.url.match(/(?:http[s]*\:\/\/)*(.*?)\.(?=[^\/]*\..{2,5})/i)[1]
|
||||||
return {
|
return {
|
||||||
onDelete: this._handleDelete,
|
onDelete: this._handleDelete,
|
||||||
onObjectSave: this._handleObjectSave,
|
onObjectSave: this._handleObjectSave,
|
||||||
|
Loading…
Reference in New Issue
Block a user