Skip to content

Commit 35e3140

Browse files
committed
replaced binserve with http-server, skip preprocessing if files didn't change
1 parent ed601cb commit 35e3140

File tree

16 files changed

+771
-71
lines changed

16 files changed

+771
-71
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ node_modules
1313
/static/input
1414
/static/data
1515
/releases/bin/preprocess.exe
16+
/releases/bin/http-server.exe
1617
/releases/static/
1718
/releases/*.zip
1819
/_temp_input/

BUILD_RELEASE.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ del releases\bin\preprocess.exe
1111
cd preprocess
1212
pyinstaller preprocess.py -F
1313
cd ..
14+
call pkg server/node_modules/http-server/bin/http-server --target node16-win-x64
1415
@REM Move build to releases
1516
move "preprocess\dist\preprocess.exe" "releases\bin\preprocess.exe"
17+
move "http-server.exe" "releases\bin\http-server.exe"
1618

1719
@REM Build sveltekit frontend
1820
call npm run build

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,22 @@ npm run dev -- --open
9292
```
9393
py -m pip install pyinstaller
9494
```
95+
pkg (installed globally)
96+
```
97+
npm install -g pkg
98+
```
9599

96100
## Steps
97101
1. Clone this repository
98102
```bash
99-
git clone URL
103+
git clone https://github.com/slatinsky/DiscordChatExporter-frontend
100104
```
101105
2. Install dependencies
102106
```bash
103107
npm install
108+
cd server
109+
npm install
110+
cd ..
104111
```
105112
3. Make sure you have Python3.9+ Node.js 16 and pyinstaller installed:
106113
```
@@ -144,8 +151,8 @@ v16.14.2
144151
>pyinstaller --version
145152
5.5
146153
147-
Binserve version:
148-
binserve-v0.2.0-i686-pc-windows-msvc
154+
>pkg --version
155+
5.8.0
149156
150157
DiscordChatExporter version:
151158
v2.36.1
@@ -183,15 +190,12 @@ But should work on any Windows 10 / Windows 11 x64 computer.
183190
- [Tyrrrz/DiscordChatExporter](https://github.com/Tyrrrz/DiscordChatExporter) - for a great tool. Many CSS definitions from this tool are used in our viewer.
184191
- Discord - for a great chat app
185192
- pyinstaller - for python to binary converter
186-
- [mufeedvh/binserve](https://github.com/mufeedvh/binserve) - for local webserver binary
187193
- [brussell98/discord-markdown](https://github.com/brussell98/discord-markdown) - for discord markdown rendering
188194

189195

190196
## License
191197
GNU GENERAL PUBLIC LICENSE
192198

193-
included binserve binary uses MIT license
194-
195199
## Contributing
196200
Feel free to open issues and pull requests.
197201

preprocess/preprocess.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,49 @@ def _find_all_mediafiles_paths(self, directory):
396396
# self.guilds = sorted(self.guilds, key=lambda d: d['name'])
397397
# return
398398

399+
def should_process(self, json_files, media_filepaths):
400+
file_count = len(json_files) + len(media_filepaths)
401+
print("Found " + str(file_count) + " files")
402+
403+
# make directory if it doesn't exist
404+
if not os.path.exists('../static/data'):
405+
os.makedirs('../static/data')
406+
407+
# if data/hash.txt does exists read the hash
408+
if os.path.exists('../static/data/hash.txt'):
409+
with open('../static/data/hash.txt', 'r') as f:
410+
hash_from_file = f.read()
411+
print("Hash: " + hash_from_file)
412+
else:
413+
print("Hash file does not exist")
414+
hash_from_file = None
415+
416+
417+
# create hash of all files
418+
# if hash is the same, then we can skip processing
419+
# because reprocessing takes a lot of time
420+
new_hash = sha256((str(json_files) + str(media_filepaths)).encode('utf-8')).hexdigest()
421+
422+
if hash_from_file == new_hash:
423+
print("Hash is the same, skipping processing")
424+
return False
425+
else:
426+
# write new hash to file
427+
with open('../static/data/hash.txt', 'w') as f:
428+
f.write(new_hash)
429+
430+
print("Hash is different, processing")
431+
return True
432+
433+
399434
def process(self):
400435
json_files = self._find_json_files(self.input_directory)
401436
media_filepaths = self._find_all_mediafiles_paths(self.input_directory)
402437

438+
if not self.should_process(json_files, media_filepaths):
439+
print("Skipping processing")
440+
return
441+
403442
guilds = {}
404443

405444
# sort filenames by guild to attempt to split ram usage

releases/START_VIEWER.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pushd "%~dp0"
22
cd bin
33
preprocess.exe
4-
if exist "C:\Program Files\Google\Chrome\Application\chrome.exe" ("C:\Program Files\Google\Chrome\Application\chrome.exe" --app="http://127.0.0.1:1337/index.html") else (rundll32 url.dll,FileProtocolHandler http://127.0.0.1:1337/index.html)
5-
binserve.exe
4+
if exist "C:\Program Files\Google\Chrome\Application\chrome.exe" ("C:\Program Files\Google\Chrome\Application\chrome.exe" --app="http://127.0.0.1:21011/index.html") else (rundll32 url.dll,FileProtocolHandler http://127.0.0.1:21011/index.html)
5+
http-server.exe "../static" --port 21011 -c-1 --silent -P http://127.0.0.1:21011?

releases/bin/binserve.exe

-6.58 MB
Binary file not shown.

releases/bin/binserve.json

Lines changed: 0 additions & 38 deletions
This file was deleted.

releases/bin/binserve_license

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)