Skip to content

Commit b08e0a8

Browse files
Merge pull request #2 from Dynamsoft/release/v1.0.x/v1.0.2
feat: release v1.0.2
2 parents 24a0345 + b0d53a6 commit b08e0a8

21 files changed

+942
-249
lines changed

.github/workflows/main.yml

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# This is a basic workflow to help you get started with Actions
2-
31
name: CI
42

53
# Controls when the workflow will run
@@ -20,7 +18,6 @@ jobs:
2018

2119
# Steps represent a sequence of tasks that will be executed as part of the job
2220
steps:
23-
# Runs a set of commands using the runners shell
2421
- name: Get Source
2522
run: |
2623
cd /home/ubuntu
@@ -30,22 +27,21 @@ jobs:
3027
- name: Prepare Files
3128
run: |
3229
# Create a temporary directory for the files to be uploaded
33-
mkdir -p /home/ubuntu/document-scanner-javascript/demo
30+
mkdir -p /home/ubuntu/document-scanner-javascript/deploy
3431
3532
# Copy the dist folder
36-
cp -r /home/ubuntu/document-scanner-javascript/dist /home/ubuntu/document-scanner-javascript/demo
33+
cp -r /home/ubuntu/document-scanner-javascript/dist /home/ubuntu/document-scanner-javascript/deploy
3734
38-
# Copy the samples folder and rename demo.html to index.html
39-
cp -r /home/ubuntu/document-scanner-javascript/samples/* /home/ubuntu/document-scanner-javascript/demo
40-
mv /home/ubuntu/document-scanner-javascript/demo/demo.html /home/ubuntu/document-scanner-javascript/demo/index.html
35+
# Copy demo and hello world. On demo branch, be sure to update the pathing for the demo
36+
cp -r /home/ubuntu/document-scanner-javascript/samples/demo/* /home/ubuntu/document-scanner-javascript/deploy
37+
cp -r /home/ubuntu/document-scanner-javascript/samples/hello-world.html /home/ubuntu/document-scanner-javascript/deploy
4138
42-
4339
- name: Sync files
4440
uses: SamKirkland/[email protected]
4541
with:
4642
server: ${{ secrets.FTP_DEMO_SERVER }}
4743
username: ${{ secrets.FTP_DEMO_USERNAME }}
4844
password: ${{ secrets.FTP_DEMO_PASSWORD }}
4945
port: 21
50-
local-dir: /home/ubuntu/document-scanner-javascript/demo/
51-
server-dir: /Demo.dynamsoft.com/document-scanner/
46+
local-dir: /home/ubuntu/document-scanner-javascript/deploy/
47+
server-dir: /Demo.dynamsoft.com/document-scanner/

README.md

+554-77
Large diffs are not rendered by default.

dev-server/index.js

+62-14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import formidable from "formidable";
12
import express from "express";
23
import fs from "fs";
34
import http from "http";
@@ -32,23 +33,69 @@ app.use(
3233

3334
// Serve static files
3435
app.use("/dist", express.static(distPath));
35-
app.use("/assets", express.static(path.join(__dirname, "../samples/assets")));
36-
app.use("/css", express.static(path.join(__dirname, "../samples/css")));
37-
app.use("/font", express.static(path.join(__dirname, "../samples/font")));
36+
app.use("/assets", express.static(path.join(__dirname, "../samples/demo/assets")));
37+
app.use("/css", express.static(path.join(__dirname, "../samples/demo/css")));
38+
app.use("/font", express.static(path.join(__dirname, "../samples/demo/font")));
3839

3940
// Routes
4041
app.get("/", (req, res) => {
41-
res.sendFile(path.join(__dirname, "../samples/demo.html"));
42+
res.sendFile(path.join(__dirname, "../samples/hello-world.html"));
4243
});
4344

4445
app.get("/demo", (req, res) => {
45-
res.sendFile(path.join(__dirname, "../samples/demo.html"));
46+
res.sendFile(path.join(__dirname, "../samples/demo/index.html"));
4647
});
4748

4849
app.get("/hello-world", (req, res) => {
4950
res.sendFile(path.join(__dirname, "../samples/hello-world.html"));
5051
});
5152

53+
// Allow upload feature
54+
app.post("/upload", function (req, res) {
55+
try {
56+
// Create a new Formidable form
57+
const form = formidable({
58+
multiples: false,
59+
keepExtensions: true,
60+
});
61+
62+
form.parse(req, (err, fields, files) => {
63+
if (err) {
64+
console.error(err);
65+
return res.status(500).send("Error processing the file upload.");
66+
}
67+
68+
const uploadedFile = files.uploadFile[0]; // Ensure the file field name matches the form
69+
if (!uploadedFile) {
70+
return res.status(400).json({ success: false, message: "No file uploaded" });
71+
}
72+
73+
// Get current timestamp
74+
let dt = new Date();
75+
76+
const fileSavePath = path.join(__dirname, "\\");
77+
const newFileName = uploadedFile.originalFilename;
78+
const newFilePath = path.join(fileSavePath, newFileName);
79+
80+
// Move the uploaded file to the desired directory
81+
fs.rename(uploadedFile.filepath, newFilePath, (err) => {
82+
if (err) {
83+
console.error(err);
84+
return res.status(500).send("Error saving the file.");
85+
}
86+
console.log(`\x1b[33m ${newFileName} \x1b[0m uploaded successfully!`);
87+
});
88+
res.status(200).json({
89+
success: true,
90+
message: `${newFileName} uploaded successfully`,
91+
filename: newFileName,
92+
});
93+
});
94+
} catch (error) {
95+
res.status(500).send("An error occurred during file upload.");
96+
}
97+
});
98+
5299
let httpPort = 3000;
53100
let httpsPort = 3001;
54101

@@ -107,10 +154,11 @@ httpsServer.on("error", (error) => {
107154

108155
// Start the servers
109156
httpServer.listen(httpPort, () => {
110-
console.log("\n\x1b[1m Dynamsoft Document Scanner Sample\x1b[0m\n");
111-
console.log("\x1b[36m Access URLs:\x1b[0m");
157+
console.log("\n\x1b[1m Dynamsoft Document Scanner Samples\x1b[0m\n");
158+
console.log("\x1b[36m HTTP URLs:\x1b[0m");
112159
console.log("\x1b[90m-------------------\x1b[0m");
113-
console.log("\x1b[32m Local:\x1b[0m http://localhost:" + httpPort + "/");
160+
console.log("\x1b[33m Hello World:\x1b[0m http://localhost:" + httpPort + "/hello-world");
161+
console.log("\x1b[33m Demo:\x1b[0m http://localhost:" + httpPort + "/demo");
114162
});
115163

116164
httpsServer.listen(httpsPort, "0.0.0.0", () => {
@@ -124,13 +172,13 @@ httpsServer.listen(httpsPort, "0.0.0.0", () => {
124172
});
125173
});
126174

175+
console.log("\n");
176+
console.log("\x1b[36m HTTPS URLs:\x1b[0m");
177+
console.log("\x1b[90m-------------------\x1b[0m");
127178
ipv4Addresses.forEach((localIP) => {
128-
console.log("\x1b[32m Network:\x1b[0m https://" + localIP + ":" + httpsPort + "/");
179+
console.log("\x1b[32m Hello World:\x1b[0m https://" + localIP + ":" + httpsPort + "/hello-world");
180+
console.log("\x1b[32m Demo:\x1b[0m https://" + localIP + ":" + httpsPort + "/demo");
129181
});
130-
console.log("\x1b[36m Available Pages:\x1b[0m");
131-
console.log("\x1b[90m-------------------\x1b[0m");
132-
console.log("\x1b[33m Demo:\x1b[0m /demo");
133-
console.log("\x1b[33m Hello World:\x1b[0m /hello-world\n");
134-
182+
console.log("\n");
135183
console.log("\x1b[90mPress Ctrl+C to stop the server\x1b[0m\n");
136184
});

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dynamsoft-document-scanner",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Dynamsoft Document Scanner (DDS) is a ready-to-use SDK for capturing and enhancing document images with automatic border detection, correction, and customizable workflows.",
55
"files": [
66
"/dist",
File renamed without changes.
File renamed without changes.
File renamed without changes.

samples/demo.html renamed to samples/demo/index.html

+93-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,68 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Dynamsoft Document Scanner</title>
7-
<script src="../dist/dds.bundle.js"></script>
7+
<script src="../../dist/dds.bundle.js"></script>
88
<link rel="stylesheet" href="./css/index.css" />
9+
<style id="rotate-phone-style">
10+
.rotation-message {
11+
position: fixed;
12+
top: 0;
13+
left: 0;
14+
right: 0;
15+
bottom: 0;
16+
background: rgba(0, 0, 0, 0.9);
17+
display: flex;
18+
justify-content: center;
19+
align-items: center;
20+
z-index: 9999;
21+
color: white;
22+
}
23+
24+
.rotation-content {
25+
display: flex;
26+
flex-direction: column;
27+
align-items: center;
28+
gap: 1rem;
29+
padding: 2rem;
30+
text-align: center;
31+
}
32+
33+
.rotation-content svg {
34+
width: 48px;
35+
height: 48px;
36+
animation: rotate 2s infinite linear;
37+
}
38+
39+
@keyframes rotate {
40+
from {
41+
transform: rotate(0deg);
42+
}
43+
to {
44+
transform: rotate(360deg);
45+
}
46+
}
47+
</style>
948
</head>
1049
<body>
50+
<div id="rotationMessage" class="rotation-message" style="display: none">
51+
<div class="rotation-content">
52+
<svg
53+
xmlns="http://www.w3.org/2000/svg"
54+
width="24"
55+
height="24"
56+
viewBox="0 0 24 24"
57+
fill="none"
58+
stroke="currentColor"
59+
stroke-width="2"
60+
stroke-linecap="round"
61+
stroke-linejoin="round"
62+
>
63+
<path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8" />
64+
<path d="M21 3v5h-5" />
65+
</svg>
66+
<span>Please rotate your device to portrait mode</span>
67+
</div>
68+
</div>
1169
<div class="col1">
1270
<!-- Logo -->
1371
<a class="logo-container" href="https://www.dynamsoft.com" target="_blank">
@@ -202,6 +260,40 @@ <h1 class="title">Dynamsoft Document Scanner</h1>
202260
// Event listeners
203261
scanButton.addEventListener("click", handleScan);
204262
shareButton.addEventListener("click", handleShare);
263+
264+
// Rotate Phone
265+
function isMobile() {
266+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
267+
}
268+
269+
// Function to handle orientation change
270+
function handleOrientation() {
271+
const rotationMessage = document.getElementById("rotationMessage");
272+
if (isMobile()) {
273+
if (window.orientation === 90 || window.orientation === -90) {
274+
rotationMessage.style.display = "flex";
275+
} else {
276+
rotationMessage.style.display = "none";
277+
}
278+
}
279+
}
280+
281+
// Listen for orientation changes
282+
window.addEventListener("orientationchange", handleOrientation);
283+
// Also check on load
284+
handleOrientation();
285+
286+
// Alternative method for browsers that don't support window.orientation
287+
window.matchMedia("(orientation: landscape)").addListener(function (e) {
288+
const rotationMessage = document.getElementById("rotationMessage");
289+
if (isMobile()) {
290+
if (e.matches) {
291+
rotationMessage.style.display = "flex";
292+
} else {
293+
rotationMessage.style.display = "none";
294+
}
295+
}
296+
});
205297
</script>
206298
</body>
207299
</html>

samples/hello-world.html

-10
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Dynamsoft Document Scanner - Hello World</title>
77
<script src="../dist/dds.bundle.js"></script>
8-
<style>
9-
html,
10-
body {
11-
margin: 0;
12-
padding: 0;
13-
box-sizing: border-box;
14-
font-family: Arial, sans-serif;
15-
background-color: #f9f9f9;
16-
}
17-
</style>
188
</head>
199

2010
<body>

0 commit comments

Comments
 (0)