Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

staging -> production #68

Merged
merged 34 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0826148
video landing page
petyosi Nov 25, 2022
2a20162
chore: more features
petyosi Nov 25, 2022
3c35ef0
chore: more content
petyosi Nov 28, 2022
9e24f94
chore: fix the url
petyosi Dec 1, 2022
6107b43
chore: more sections in video
petyosi Dec 2, 2022
6543a7b
chore: go syntax highlight
petyosi Dec 6, 2022
1c7746c
chore: usable dropdown for video
petyosi Dec 6, 2022
f62391b
chore: style tutorials stage
petyosi Dec 6, 2022
3ed7c94
chore: features layout/content
petyosi Dec 7, 2022
533c8e4
fix: react native video link (#61)
santhoshvai Dec 8, 2022
bfc4627
chore: video homepage moved to docs repo
petyosi Dec 9, 2022
0f50050
chore: fix anchor
petyosi Dec 9, 2022
35420ea
Adding client js to consts
vanGalilea Feb 28, 2023
a94facd
Update constants.js
vanGalilea Mar 1, 2023
888fad3
Merge branch 'staging' into vanGalilea-patch-2
vanGalilea Mar 1, 2023
8450866
Merge pull request #63 from GetStream/vanGalilea-patch-2
vanGalilea Mar 1, 2023
36760ca
Revert "feat: adding client js to consts"
khushal87 Mar 2, 2023
1757fb6
Merge pull request #64 from GetStream/revert-63-vanGalilea-patch-2
vanGalilea Mar 2, 2023
5081618
api
tbarbugli Jun 6, 2023
e5780ea
Remove Platform and Overview from build output
DaemonLoki Jun 7, 2023
757d303
Update Layout.js to prevent redirect loop on /video/docs/
Jun 8, 2023
7ed2324
Add TokenSnippet to shared content
DaemonLoki Jun 8, 2023
1651832
Move shared snippet to correct place and update README
DaemonLoki Jun 8, 2023
8f4c58f
Merge pull request #66 from GetStream/jaapbakker88-patch-1
Jun 12, 2023
ed3e7df
Disable ReactNative
jeroenleenarts Jun 12, 2023
e09e5d4
Disable Video ReactNative, not Chat.
jeroenleenarts Jun 12, 2023
b0ff8a2
Disable everything ReactNative.
jeroenleenarts Jun 13, 2023
28808ec
Update tokenSnippet to real use real API
DaemonLoki Jun 13, 2023
20aa4ab
Add option to either show join call or credentials only
jeroenleenarts Jun 14, 2023
f9d70ba
Adopt changes by Stefan
jeroenleenarts Jun 14, 2023
f040cf4
Refactor
DaemonLoki Jun 14, 2023
eb4f655
Add session storage to token snippet
DaemonLoki Jun 14, 2023
c9ee3d4
Prevent different credentials for multiple elements on a page
DaemonLoki Jun 14, 2023
9fc7838
Make sure each .sampleApp uses a distinct storage key.
jeroenleenarts Jun 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ yarn-error.log
.DS_Store
/.log/
.docusaurus
*_version*
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,16 @@ git clone https://github.com/getstream/stream-chat-docusaurus-cli

cd stream-chat-docusaurus-cli

# Install dependencies
# Run the install command

yarn

# link the package so that npx picks it

npm link
npm install -g
```

Within the same directory level of your SDK that the `docusaurus` directory described above lives you can run CLI commands. Make sure you have at least the directory structure described above as well as at least 1 markdown file.

### Starting

To run the site locally and see your documentation, run `npx stream-chat-docusaurus -s`.
To run the site locally and see your documentation, run `npx stream-chat-docusaurus -s`.

### Environment variables

Expand Down Expand Up @@ -114,17 +110,14 @@ You can add your own sidebar instead of the auto-generated default by creating a
To share content between multiple SDKs, put markdown files in the `shared` directory. During run, it will be symlinked next to your content.

```sh
- docusaurus
- React
- Android
- iOS
- shared # this will be symlink to the shared directory
- shared
- <your-shared-file> # this will be symlink to the shared directory
```

Then, import and render the shared content using mdx:

```mdx
import SharedContent from '../../../shared/_example-shared-content.md'
import SharedContent from '../../../shared/_example-shared-content.md';

<SharedContent />
```
Expand Down
16 changes: 15 additions & 1 deletion constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const folderMapping = {
react: 'React',
reactnative: 'React Native',
angular: 'Angular',
api: 'API',
};

const platformMapping = {
Expand All @@ -13,7 +14,8 @@ const platformMapping = {
ios: 'ios-swift',
react: 'react',
reactnative: 'react-native',
angular: 'angular'
angular: 'angular',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have different mappings for video and chat?
Because in video we don't have angular yet.

api: 'api',
};

const languageMapping = {
Expand All @@ -23,6 +25,7 @@ const languageMapping = {
react: 'javascript',
reactnative: 'javascript',
angular: 'javascript',
api: 'javascript',
};

const DOCUSAURUS_INDEX =
Expand All @@ -31,11 +34,22 @@ const CMS_INDEX = 'DOCS';

const IGNORED_DIRECTORIES = ['common-content'];

const SDK_ORDER = [
'react',
'ios',
'android',
'reactnative',
'flutter',
'angular',
'api',
];

module.exports = {
IGNORED_DIRECTORIES,
DOCUSAURUS_INDEX,
CMS_INDEX,
folderMapping,
platformMapping,
languageMapping,
SDK_ORDER,
};
46 changes: 41 additions & 5 deletions docusaurus.config.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused.
Wouldn't the changes we've done here for the video docs also affect the chat ones?
Or what am I missing here?

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ if (!process.env.PRODUCT) {
process.env.PRODUCT = 'chat';
}

const { folderMapping, IGNORED_DIRECTORIES } = require('./constants');
const {
folderMapping,
IGNORED_DIRECTORIES,
SDK_ORDER,
} = require('./constants');
const URLS = require('./urls');
const productVariables = require('./src/product-variables');
const Icons = require('./admonition-icons');
Expand All @@ -33,12 +37,21 @@ const {
docusaurus: { title: navbarTitle },
} = productVariables[PRODUCT];

const SDK_FOLDERS = DOCS_DIR.filter((file) => {
let SDK_FOLDERS = DOCS_DIR.filter((file) => {
if (PRODUCT === 'video' && file === 'reactnative') {
return false;
}
return fs
.lstatSync(`${STREAM_SDK_DOCUSAURUS_PATH}/docs/${file}`)
.isDirectory();
});

SDK_FOLDERS = SDK_FOLDERS.sort((a, b) => {
const aIndex = SDK_ORDER.indexOf(a.toLowerCase()) ?? 1000;
const bIndex = SDK_ORDER.indexOf(b.toLowerCase()) ?? 1000;
return aIndex - bIndex;
});

const CUSTOM_PLUGIN_FILES = DOCUSAURUS_DIR_CONTENTS.filter((file) =>
getCustomPluginRegExp().test(file)
);
Expand Down Expand Up @@ -179,6 +192,15 @@ const navbarSDKItems = SDK_FOLDERS.map((SDK) => {
};
});

// create sections in the dropdown by inserting two dividers.
if (process.env.PRODUCT === 'video') {
navbarSDKItems.splice(0, 0, {
label: 'SDKs',
className: 'navbar__break',
href: '#',
});
}

const navbarVersionItems = SDK_FOLDERS.map((SDK) => ({
docsPluginId: SDK.toLowerCase().replace(' ', ''),
type: 'docsVersionDropdown',
Expand All @@ -205,9 +227,10 @@ const navbarItems = [
];

if (navbarSDKItems.length > 1) {
const label = process.env.PRODUCT === 'video' ? 'Video docs' : 'SDK';
navbarItems.push({
items: navbarSDKItems,
label: 'SDK',
label,
className: 'navbar__link__custom-dropdown--sdks',
position: 'left',
});
Expand All @@ -226,8 +249,21 @@ if (process.env.DEPLOYMENT_ENV === 'production') {
]);
}

/**
* For video, we want to embed the homepage in the content repository.
*/
if (process.env.SOURCE_HOMEPAGE) {
plugins.push([
'@docusaurus/plugin-content-pages',
{
path: path.join(STREAM_SDK_DOCUSAURUS_PATH, 'pages'),
},
]);
} else {
plugins.push('@docusaurus/plugin-content-pages');
}

plugins.push(
'@docusaurus/plugin-content-pages',
'docusaurus-plugin-sass',
path.resolve(__dirname, 'src/symlink-docusaurus'),
path.resolve(__dirname, 'src/define-env-vars-plugin'),
Expand All @@ -243,7 +279,7 @@ module.exports = {
organizationName: 'GetStream',
plugins,
projectName: `stream-${PRODUCT}`,
tagline: `Stream ${productTitle} official component SDKs`,
tagline: `Stream ${productTitle} Component SDKs`,
themeConfig: {
// Docusaurus forces us to pass these values even if they are not internally used.
// Theyre only used to show/hide the search bar in our case.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-toastify": "^7.0.4",
"remark-admonitions": "^1.2.1",
"sass": "^1.34.0",
"viz.js": "1.8.0"
},
Expand Down
142 changes: 142 additions & 0 deletions shared/_tokenSnippet.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import React from 'react';
import './tokenSnippet.css';

const BASE_URL = 'https://stream-calls-dogfood.vercel.app/api/call/sample?';

const STORAGE_KEY = 'tokenSnippetDataFor';

async function callAPI(sampleApp) {
const constructedUrl = constructUrl(sampleApp);
const response = await fetch(constructedUrl);
const resultObject = await response.json();
return resultObject;
}

function constructUrl(sampleApp) {
return (
BASE_URL +
new URLSearchParams({
app_type: sampleApp,
})
);
}

export class TokenSnippet extends React.Component {
constructor(props) {
super(props);
this.state = {
loadingFinished: false,
sampleApp: props.sampleApp,
userId: 'Loading ...',
userName: 'Creating user name ...',
callId: 'Creating random call ID ...',
callType: 'Loading call type ...',
apiKey: 'Waiting for an API key ...',
token: 'Token is generated ...',
deepLink: 'Link is created ...',
displayStyle: props.displayStyle ?? 'full',
};
}

componentDidMount() {
const storedData = sessionStorage.getItem(STORAGE_KEY + this.state.sampleApp);
if (storedData) {
this.setState({
...this.state,
loadingFinished: true,
...JSON.parse(storedData),
});
} else {
callAPI(this.state.sampleApp).then((result) => {
const savedData = sessionStorage.getItem(STORAGE_KEY + this.state.sampleApp);
// We're checking again if another component might have written
// the data in the meantime. This is not ideal, but it works for now.
// (This happens for multiple elements on the same page)
if (savedData) {
this.setState({
...this.state,
loadingFinished: true,
...JSON.parse(savedData),
});
} else {
sessionStorage.setItem(STORAGE_KEY + this.state.sampleApp, JSON.stringify(result));
this.setState({
...this.state,
loadingFinished: true,
...result,
});
}
});
}
}

render() {
const showTable =
this.state.displayStyle === 'full' ||
this.state.displayStyle === 'credentials';

const showJoinLink =
this.state.displayStyle === 'full' || this.state.displayStyle === 'join';

return (
<div className="snippetStyle">
{showTable && (
<div>
<p>Here are credentials to try out the app with:</p>
<table className="snippetTable">
<thead>
<tr>
<th>Property</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>API Key</td>
<td>{this.state.apiKey}</td>
</tr>
<tr>
<td>Token</td>
<td className="tokenStyle">
<span> {this.state.token}</span>
{this.state.loadingFinished && (
<button
onClick={() =>
navigator.clipboard.writeText(this.state.token)
}
>
Copy
</button>
)}
</td>
</tr>
<tr>
<td>User ID</td>
<td>{this.state.userId}</td>
</tr>
<tr>
<td>Call ID</td>
<td>{this.state.callId}</td>
</tr>
</tbody>
</table>
</div>
)}

{showJoinLink && (
<span className="joinCallRow">
For testing you can join the call on our web-app:{' '}
<a
target="_blank"
rel="noreferrer noopener"
href={this.state.deepLink}
className="joinCallLink"
>
Join Call
</a>
</span>
)}
</div>
);
}
}
Loading