diff --git a/packages/server/assets/homepage.html b/packages/server/assets/homepage.html
index 85a181e7..ccdcd0c6 100644
--- a/packages/server/assets/homepage.html
+++ b/packages/server/assets/homepage.html
@@ -7,7 +7,7 @@
rel="stylesheet">
-
diff --git a/packages/server/router/index.ts b/packages/server/router/index.ts
index af8c6e1b..a1ae1a69 100644
--- a/packages/server/router/index.ts
+++ b/packages/server/router/index.ts
@@ -13,6 +13,7 @@ import path from 'path';
import { HttpServer, getContentType, sendJson } from '../index';
import {
buildExternalCounters,
+ buildInstructionLocal,
buildLocalCounters,
buildSettings
} from '../utils/counters';
@@ -332,6 +333,10 @@ export default function buildBaseApi(app: HttpServer) {
return buildSettings(res);
}
+ if (req.query?.tab == '3') {
+ return buildInstructionLocal(res);
+ }
+
return buildLocalCounters(res);
}
diff --git a/packages/server/utils/counters.ts b/packages/server/utils/counters.ts
index e87a4508..6bbde58c 100644
--- a/packages/server/utils/counters.ts
+++ b/packages/server/utils/counters.ts
@@ -99,6 +99,11 @@ function rebuildJSON({
const name = nameHTML.replace('{NAME}', item.name);
const author = authorHTML.replace('{AUTHOR}', item.author);
+ const counterName =
+ (item.author || '').toLowerCase() == 'local'
+ ? item.name
+ : `${item.name} by ${item.author}`;
+
const links = item.authorlinks
.map((r) => {
const domain =
@@ -118,38 +123,50 @@ function rebuildJSON({
const iframe = iframeHTML
.replace(
'{URL}',
- `http://${config.serverIP}:${config.serverPort}/${item.name} by ${item.author}/`
+ `http://${config.serverIP}:${config.serverPort}/${counterName}/`
)
.replace(
'{WIDTH}',
- item.resolution[0] == -1 ? '500' : `${item.resolution[0]}px`
+ item.resolution[0] == -1
+ ? '500px'
+ : item.resolution[0] == -2
+ ? '100%'
+ : `${item.resolution[0]}px`
)
.replace(
'{HEIGHT}',
- item.resolution[1] == -1 ? '500' : `${item.resolution[1]}px`
+ item.resolution[1] == -1 ? '500px' : `${item.resolution[1]}px`
);
const metadata = metadataHTML
.replace(
'{COPY_URL}',
- `http://${config.serverIP}:${config.serverPort}/${item.name} by ${item.author}/`
+ `http://${config.serverIP}:${config.serverPort}/${counterName}/`
)
- .replace('{TEXT_URL}', `/${item.name} by ${item.author}/`)
+ .replace('{TEXT_URL}', `/${counterName}/`)
.replace(
'{COPY_X}',
- item.resolution[0] == -1 ? 'ANY' : item.resolution[0].toString()
+ item.resolution[0] == -1 || item.resolution[0] == -2
+ ? 'ANY'
+ : item.resolution[0].toString()
)
.replace(
'{X}',
- item.resolution[0] == -1 ? 'ANY' : item.resolution[0].toString()
+ item.resolution[0] == -1 || item.resolution[0] == -2
+ ? 'ANY'
+ : item.resolution[0].toString()
)
.replace(
'{COPY_Y}',
- item.resolution[1] == -1 ? 'ANY' : item.resolution[1].toString()
+ item.resolution[1] == -1 || item.resolution[1] == -2
+ ? 'ANY'
+ : item.resolution[1].toString()
)
.replace(
'{Y}',
- item.resolution[1] == -1 ? 'ANY' : item.resolution[1].toString()
+ item.resolution[1] == -1 || item.resolution[1] == -2
+ ? 'ANY'
+ : item.resolution[1].toString()
);
const button = item.downloadLink
@@ -190,14 +207,34 @@ function getLocalCounters() {
config.staticFolderPath ||
path.join(path.dirname(process.execPath), 'static');
- const countersList = recursiveFilesSearch({
+ const countersListTXT = recursiveFilesSearch({
dir: staticPath,
fileList: [],
filename: 'metadata.txt'
});
- const array = countersList.map((r) => parseTXT(r));
- return array;
+ const countersListHTML = recursiveFilesSearch({
+ dir: staticPath,
+ fileList: [],
+ filename: 'index.html'
+ });
+
+ const arrayOfLocal = countersListHTML
+ .filter((r) => {
+ const folder = path.dirname(r);
+ return (
+ countersListTXT.find((s) => path.dirname(s) == folder) == null
+ );
+ })
+ .map((r) => ({
+ name: path.basename(path.dirname(r)),
+ author: 'local',
+ resolution: [-2, '400'],
+ authorlinks: []
+ }));
+
+ const array = countersListTXT.map((r) => parseTXT(r));
+ return array.concat(arrayOfLocal);
}
export function buildLocalCounters(res: http.ServerResponse, query?: string) {
@@ -416,3 +453,29 @@ export function buildSettings(res: http.ServerResponse) {
}
);
}
+
+export function buildInstructionLocal(res: http.ServerResponse) {
+ const pageContent = `
+
How to Add Your Own Counter Locally
+
+ 1. Create a new folder:
- First, create a new folder inside your static folder.
+ 2. Move your pp counter files:
- Next, move your pp counter files into the newly created folder.
+ 3. Download and place metadata file:
- Download the metadata.txt file and place it in the counter folder.
+ 4. Fill out the metadata file:
- Finally, open the metadata.txt file and fill out the necessary information.
+
+
`;
+ fs.readFile(
+ 'F:/coding/wip/tosu/packages/server/assets/homepage.html',
+ 'utf8',
+ (err, content) => {
+ const html = content.replace('{{LIST}}', pageContent);
+
+ res.writeHead(200, {
+ 'Content-Type': getContentType('file.html')
+ });
+ res.end(html);
+ }
+ );
+}