Skip to content

Commit d843ff3

Browse files
Tom-DynamsoftJustin-dynamsoftCopilot
authored
Improve ZIP package developer experience (#301)
* Improve ZIP package first impression (P0 items) - Move hello-world/scan-single/read-image into basics/ subdirectory - Inline favicon (base64) and logo SVG into index.html, remove loose files - Fix scan-a-single-barcode.html title (was copy-pasted from hello-world) - Add meta description, keywords, and canonical tags to all basics samples - Update all links in index.html and README.md to reflect new paths EOF ) * Fix remaining P0 issues and add README.html - Fix canonical URL in read-an-image.html (missing basics/ path) - Fix canonical URL in read-and-parse-GS1-AI (wrong sub-path) - Add LICENSE ALERT comment to hello-world.html and scan-a-single-barcode.html for consistency - Fix documentation link in README.md (point to user-guide) - Add styled README.html for local/ZIP readability * Align README.html and README.md content * Add file:// detection tip to camera-based basics samples Show a non-blocking yellow banner when opened via file:// suggesting the user serve the page from a web server for the best experience. * Add .gitattributes to slim down ZIP downloads * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Justin-dynamsoft <117710848+Justin-dynamsoft@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 357a86b commit d843ff3

10 files changed

Lines changed: 307 additions & 66 deletions

File tree

.gitattributes

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Exclude files not needed in the ZIP download (GitHub "Download ZIP" / git archive).
2+
# These are development or CI artifacts that don't help end users run the samples.
3+
4+
# CI/CD and internal tooling
5+
.github/** export-ignore
6+
7+
# Git-only files (not useful without a git repo)
8+
.gitattributes export-ignore
9+
.gitignore export-ignore
10+
.gitkeep export-ignore
11+
12+
# Editor configuration
13+
.editorconfig export-ignore
14+
15+
# Root logo file (already inlined in README.html)
16+
logo-dynamsoft-black.svg export-ignore

README.html

Lines changed: 212 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ git clone https://github.com/Dynamsoft/barcode-reader-javascript-samples.git --d
5858

5959
## Running the Samples Locally
6060

61-
The standalone samples (`hello-world.html`, `scan-a-single-barcode.html`, `read-an-image.html`) and scenario samples load the SDK from a CDN, so you can open them directly by double-clicking — no web server required (an internet connection is needed).
61+
The standalone samples in the `basics/` folder (`hello-world.html`, `scan-a-single-barcode.html`, `read-an-image.html`) and scenario samples load the SDK from a CDN, so you can open them directly by double-clicking — no web server required (an internet connection is needed).
6262

6363
To browse all available samples, open `index.html` in your browser — it links to every sample in the repository.
6464

@@ -74,17 +74,17 @@ If you need a web server for standalone or scenario samples (for example, to ser
7474

7575
## Sample Folders
7676

77-
The repository includes two main sample directories:
78-
79-
- **`frameworks/`** - Framework-specific examples demonstrating how to integrate Dynamsoft Barcode Reader into common web and hybrid frameworks.
77+
- **`basics/`** - Three foundational samples: hello-world, scan-a-single-barcode, and read-an-image.
8078

8179
- **`scenarios/`** - Focused scenario samples that show common real-world uses of Dynamsoft Barcode Reader.
8280

81+
- **`frameworks/`** - Framework-specific examples demonstrating how to integrate Dynamsoft Barcode Reader into common web and hybrid frameworks.
82+
8383
---
8484

8585
## Documentation
8686

87-
For the developer guide and full API reference of Dynamsoft Barcode Reader JavaScript library, please check out the [documentation](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/?ver=11.4.2001&utm_source=sampleReadme).
87+
For the developer guide and full API reference of Dynamsoft Barcode Reader JavaScript library, please check out the [documentation](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/index.html?utm_source=sampleReadme).
8888

8989
- [API Docs](https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/api-reference/index.html?utm_source=sampleReadme)
9090

@@ -100,9 +100,9 @@ If you have any questions, feel free to [contact Dynamsoft support](https://www.
100100

101101
### Hello World
102102

103-
- [hello-world.html](./hello-world.html) — Demonstrates continuously scanning and collecting multiple unique barcodes via camera.
104-
- [scan-a-single-barcode.html](./scan-a-single-barcode.html) — Demonstrates single-barcode scanning: stops and returns as soon as the first barcode is detected.
105-
- [read-an-image.html](./read-an-image.html) — Demonstrates how to decode and read barcodes from uploaded image files.
103+
- [hello-world.html](./basics/hello-world.html) — Demonstrates continuously scanning and collecting multiple unique barcodes via camera.
104+
- [scan-a-single-barcode.html](./basics/scan-a-single-barcode.html) — Demonstrates single-barcode scanning: stops and returns as soon as the first barcode is detected.
105+
- [read-an-image.html](./basics/read-an-image.html) — Demonstrates how to decode and read barcodes from uploaded image files.
106106

107107
### Frameworks
108108

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
<head>
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<meta name="description" content="Continuously scan and collect multiple unique barcodes via camera with Dynamsoft Barcode Reader." />
8+
<meta name="keywords" content="barcode, camera, scanning" />
9+
<link rel="canonical" href="https://demo.dynamsoft.com/Samples/DBR/JS/basics/hello-world.html" />
710
<title>Dynamsoft Barcode Scanner Sample - Hello World (Decode via Camera)</title>
811

912
<!-- Include Dynamsoft Barcode Reader Bundle via CDN -->
1013
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.4.2001/dist/dbr.bundle.js"></script>
1114
<!-- If the network is unstable or you prefer to self-host the SDK, uncomment the line below to load it locally -->
12-
<!-- <script src="../dist/dbr.bundle.js"></script> -->
15+
<!-- <script src="../../dist/dbr.bundle.js"></script> -->
1316
</head>
1417

1518
<body>
@@ -20,8 +23,25 @@ <h1 class="barcode-scanner-title">
2023
<div class="barcode-scanner-view" style="width: 100%; height: 70vh;"></div>
2124
<div class="result-view" style="width: 100%; height: calc(30vh - 80px); padding: 10px;overflow: auto;"></div>
2225
<script>
26+
// Detect file:// protocol and show a helpful tip
27+
if (location.protocol === "file:") {
28+
const tip = document.createElement("div");
29+
tip.style.cssText = "background:#fff3cd;border:1px solid #ffc107;color:#856404;padding:12px 16px;margin:8px;border-radius:6px;font:14px/1.5 sans-serif;text-align:center;";
30+
tip.innerHTML = '<strong>Tip:</strong> This page works via <code>file://</code>, but for the best experience, '
31+
+ 'serve it from a web server (e.g. HTTPS or localhost).';
32+
document.body.insertBefore(tip, document.body.firstChild);
33+
}
34+
2335
const resultView = document.querySelector(".result-view");
2436

37+
/** LICENSE ALERT - README
38+
* To use the library, you need to first specify a license key.
39+
*
40+
* You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=samples&product=dbr&package=js to get your own trial license good for 30 days.
41+
* Note that if you downloaded this sample from Dynamsoft while logged in, the above license key may already be your own 30-day trial license.
42+
* For more information, see https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/index.html#license&utm_source=samples or contact support@dynamsoft.com.
43+
* LICENSE ALERT - THE END
44+
*/
2545
Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
2646
(async () => {
2747
const cameraView = await Dynamsoft.DCE.CameraView.createInstance();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
77
<meta name="description" content="Read barcodes from an image with Dynamsoft Barcode Reader." />
88
<meta name="keywords" content="barcode, image" />
9-
<link rel="canonical" href="https://demo.dynamsoft.com/Samples/DBR/JS/read-an-image.html" />
9+
<link rel="canonical" href="https://demo.dynamsoft.com/Samples/DBR/JS/basics/read-an-image.html" />
1010
<title>Dynamsoft Barcode Reader Sample - Hello World (Read an Image)</title>
1111

1212
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.4.2001/dist/dbr.bundle.js"></script>
1313
<!-- If the network is unstable or you prefer to self-host the SDK, uncomment the line below to load it locally -->
14-
<!-- <script src="../dist/dbr.bundle.js"></script> -->
14+
<!-- <script src="../../dist/dbr.bundle.js"></script> -->
1515
</head>
1616

1717
<body>
Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
<head>
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Dynamsoft Barcode Scanner Sample - Hello World (Decode via Camera)</title>
7+
<meta name="description" content="Scan a single barcode via camera and stop automatically with Dynamsoft Barcode Reader." />
8+
<meta name="keywords" content="barcode, camera, single scan" />
9+
<link rel="canonical" href="https://demo.dynamsoft.com/Samples/DBR/JS/basics/scan-a-single-barcode.html" />
10+
<title>Dynamsoft Barcode Scanner Sample - Scan a Single Barcode</title>
811

912
<!-- Include Dynamsoft Barcode Reader Bundle via CDN -->
1013
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.4.2001/dist/dbr.bundle.js"></script>
1114
<!-- If the network is unstable or you prefer to self-host the SDK, uncomment the line below to load it locally -->
12-
<!-- <script src="../dist/dbr.bundle.js"></script> -->
15+
<!-- <script src="../../dist/dbr.bundle.js"></script> -->
1316
</head>
1417

1518
<body>
@@ -20,6 +23,23 @@ <h1 class="barcode-scanner-title">
2023
<!-- This div will host the barcode scanner's camera view -->
2124
<div class="barcode-scanner-view"></div>
2225
<script>
26+
// Detect file:// protocol and show a helpful tip
27+
if (location.protocol === "file:") {
28+
const tip = document.createElement("div");
29+
tip.style.cssText = "background:#fff3cd;border:1px solid #ffc107;color:#856404;padding:12px 16px;margin:8px;border-radius:6px;font:14px/1.5 sans-serif;text-align:center;";
30+
tip.innerHTML = '<strong>Tip:</strong> This page works via <code>file://</code>, but for the best experience, '
31+
+ 'serve it from a web server (e.g. HTTPS or localhost).';
32+
document.body.insertBefore(tip, document.body.firstChild);
33+
}
34+
35+
/** LICENSE ALERT - README
36+
* To use the library, you need to first specify a license key.
37+
*
38+
* You can visit https://www.dynamsoft.com/customer/license/trialLicense?utm_source=samples&product=dbr&package=js to get your own trial license good for 30 days.
39+
* Note that if you downloaded this sample from Dynamsoft while logged in, the above license key may already be your own 30-day trial license.
40+
* For more information, see https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/index.html#license&utm_source=samples or contact support@dynamsoft.com.
41+
* LICENSE ALERT - THE END
42+
*/
2343
Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
2444
const pInit = (async () => {
2545
const cameraView = await Dynamsoft.DCE.CameraView.createInstance();

favicon.ico

-3.55 KB
Binary file not shown.

0 commit comments

Comments
 (0)