Skip to content

Commit

Permalink
Use the published package also for the demo instance
Browse files Browse the repository at this point in the history
  • Loading branch information
maksis committed Jun 28, 2024
1 parent 5666db2 commit 34e4367
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 164 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ npm-debug.log
.idea
/semantic/
/dist
/demo
npm-debug.log*
stats.html
/jest/cache
Expand Down
1 change: 1 addition & 0 deletions jest/setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
global.getBasePath = () => '/';
global.isDemoInstance = () => false;

window.$ = require('jquery');
window.jQuery = require('jquery');
Expand Down
245 changes: 126 additions & 119 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions resources/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div id="notifications-node"></div>

<script type="text/javascript">
function getBasePath(data) {
function getBasePath() {
const pathTokens = window.location.pathname.split('/');
// All basenames must used a fixed prefix because of URL routing
Expand All @@ -35,6 +35,10 @@
return '/';
}
function isDemoInstance() {
return window.location.host === 'webdemo.airdcpp.net';
};
{
// We must inject the main chunk dynamically as well because the final path is not known on compile time
Expand Down Expand Up @@ -90,20 +94,17 @@
var manifestURL = URL.createObjectURL(blob);
document.querySelector('#manifest-placeholder').setAttribute('href', manifestURL);
}
</script>

<% if (htmlWebpackPlugin.options.googleAnalytics) { %>
<script>
if (isDemoInstance()) {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-77192807-2', 'auto');
ga('send', 'pageview');
</script>
<% } %>
}
</script>

</body>
</html>
16 changes: 14 additions & 2 deletions resources/locales/pt-br/webui.main.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"info": "INFO",
"warning": "ALERTA",
"error": "ERRO",
"verbose": "VERBOSE",
"verbose": "VERBOSO",
"actions": {
"viewEvents": "Exibir eventos"
}
Expand Down Expand Up @@ -261,6 +261,9 @@
"common": {
"actions": {
"copy": "Copiar",
"copyPath": "Copiar caminho",
"copySize": "Copiar tamanho",
"copyTth": "Copiar TTH",
"download": "Download",
"downloadTo": "Baixar para...",
"findNfo": "Procurar NFO",
Expand All @@ -280,6 +283,9 @@
"notifications": {
"ignoreUserSuccess": "Usuário {{item.nicks}} foi adicionado aos usuários ignorados",
"unignoreUserSuccess": "Usuário {{item.nicks}} foi removido de usuários ignorados",
"copyPathSuccess": "O caminho foi copiado para a área de transferência",
"copySizeSuccess": "O tamanho foi copiado para a área de transferência",
"copyTTHSuccess": "O TTH foi copiado para a área de transferência",
"copyMagnetSuccess": "Link magnet foi copiado para área de transferência",
"copySuccess": "Texto foi copiado para área de transferência"
},
Expand Down Expand Up @@ -662,7 +668,13 @@
"iPv6Connectivity": "Conectividade IPv6",
"manualConfiguration": "{{status}} (configuração manual)",
"autoDetected": "{{status}} (auto detectado)",
"detecting": "Detectando..."
"detecting": "Detectando...",
"transferPort": "Porta de transferência",
"encryptedTransferPort": "Porta de transferência criptografada",
"searchUdpPort": "Porta de pesquisa/UDP",
"boundInterfaceIPv4": "Interface vinculada (IPv4)",
"boundInterfaceIPv6": "Interface vinculada (IPv6)",
"viewAll": "Mostrar tudo"
},
"ports": {
"portsAutoValuesNote": "Número das portas listadas nesta página pode ser sobrescrita por mapeadores (se habilitado)",
Expand Down
8 changes: 0 additions & 8 deletions scripts/start_demo.sh

This file was deleted.

18 changes: 0 additions & 18 deletions scripts/update_demo.sh

This file was deleted.

2 changes: 1 addition & 1 deletion src/routes/Home/components/DemoIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import LinkConstants from 'constants/LinkConstants';
import Message from 'components/semantic/Message';

const DemoIntro = () => {
if (process.env.DEMO_MODE !== '1') {
if (!isDemoInstance()) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/routes/Login/components/LoginLayoutComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const SubmitButton: React.FC<SubmitButtonProps> = ({
};

export const BottomMessage = () => {
if (process.env.DEMO_MODE !== '1') {
if (!isDemoInstance()) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/routes/Search/components/ResultTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class ResultTable extends React.Component<ResultTableProps> {

if (!searchString) {
return (
process.env.DEMO_MODE === '1' && (
isDemoInstance() && (
<Message
title="Demo content available"
icon={IconConstants.TIP}
Expand Down
1 change: 1 addition & 0 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare const getBasePath: () => string;
declare const isDemoInstance: () => boolean;

declare type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>;
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"esModuleInterop": true
},
"exclude": [
"demo",
"devtools",
"dist",
"node_modules",
Expand Down
4 changes: 0 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ if (process.argv.indexOf('-p') !== -1 && !process.env.NODE_ENV) {
process.env.SERVICEWORKER = 'sw.js';

const release = process.env.NODE_ENV === 'production';
const demo = process.env.DEMO_MODE === '1';
const chalk = require('chalk');

const parseLocaleRegex = () => {
Expand All @@ -49,7 +48,6 @@ let plugins = [

new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.env.DEMO_MODE': JSON.stringify(process.env.DEMO_MODE),
'process.env.SERVICEWORKER': JSON.stringify(process.env.SERVICEWORKER),
UI_VERSION: JSON.stringify(require('./package.json').version),
UI_BUILD_DATE: JSON.stringify(new Date().getTime()),
Expand All @@ -58,7 +56,6 @@ let plugins = [
new HtmlWebpackPlugin({
template: 'resources/index.ejs',
inject: false,
googleAnalytics: demo,
chunksSortMode: 'none',
}),
new ForkTsCheckerWebpackPlugin(),
Expand Down Expand Up @@ -103,7 +100,6 @@ plugins = plugins.concat(release ? releasePlugins : debugPlugins);
const mainEntries = ['./src/index.tsx'];

console.log(chalk.bold('[webpack] Release: ' + release));
console.log(chalk.bold('[webpack] Demo mode: ' + demo));

const chunkFilename = release ? 'js/[name].[chunkhash].chunk.js' : 'js/[name].chunk.js';

Expand Down

0 comments on commit 34e4367

Please sign in to comment.