Skip to content

Commit 9cb17ed

Browse files
committed
Add subtasks and test suite for website
1 parent f280974 commit 9cb17ed

File tree

8 files changed

+109
-66
lines changed

8 files changed

+109
-66
lines changed

package.json

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"undef": true,
3232
"unused": true,
3333
"browser": true,
34+
"mocha": true,
3435
"node": true,
3536
"globals": {
3637
"dna": false,
@@ -44,33 +45,41 @@
4445
"lint": [
4546
"jshint . --exclude-path .gitignore"
4647
],
47-
"build": [
48-
"replacer website/root website-target/1-dev",
49-
"copy-file src/resources/snap-backup-user-guide.html --folder website-target/1-dev",
50-
"copy-folder src/resources/graphics/application --ext=.png website-target/1-dev/graphics/flags --summary",
51-
"copy-folder website/graphics --ext=.png,.svg website-target/1-dev/graphics --summary",
52-
"lessc website/snap-backup.less website-target/1-dev/style.css",
53-
"uglifyjs website/snap-backup.js --output website-target/1-dev/app.min.js",
54-
"copy-folder website-target/1-dev website-target/2-stg --summary",
55-
"add-dist-header website-target/1-dev website-target/2-stg",
56-
"rev-web-assets website-target/2-stg website-target/3-rev --meta-content-base=https://snapbackup.org"
48+
"build-stage": [
49+
"replacer website/root website-target/1-stage",
50+
"copy-file src/resources/snap-backup-user-guide.html --folder website-target/1-stage",
51+
"copy-folder src/resources/graphics/application --ext=.png website-target/1-stage/graphics/flags --summary",
52+
"copy-folder website/graphics --ext=.png,.svg website-target/1-stage/graphics --summary",
53+
"lessc website/snap-backup.less website-target/1-stage/style.css",
54+
"uglifyjs website/snap-backup.js --output website-target/1-stage/app.min.js"
55+
],
56+
"build-dev": [
57+
"copy-folder website-target/1-stage website-target/2-dev --summary",
58+
"add-dist-header website-target/1-stage website-target/2-dev"
59+
],
60+
"build-prod": [
61+
"rev-web-assets website-target/2-dev website-target/3-prod --meta-content-base=https://snapbackup.org"
5762
]
5863
},
5964
"scripts": {
60-
"pretest": "run-scripts clean lint build",
61-
"test": "html-validator website-target/1-dev",
62-
"interactive": "browser-sync . --startPath website-target/1-dev --files website-target"
65+
"pretest": "run-scripts clean lint build-stage build-dev build-prod",
66+
"test": "mocha spec",
67+
"validate": "npm test && html-validator website-target/3-prod",
68+
"interactive": "npm test && browser-sync . --startPath website-target/1-stage --files website-target",
69+
"i": "npm run interactive"
6370
},
6471
"devDependencies": {
6572
"@fortawesome/fontawesome-free": "~7.1",
6673
"add-dist-header": "~1.6",
74+
"assert-deep-strict-equal": "~1.2",
6775
"browser-sync": "~3.0",
6876
"copy-file-util": "~1.3",
6977
"copy-folder-util": "~1.2",
7078
"dna-engine": "~3.3",
7179
"hamburger-menu": "~0.7",
7280
"jshint": "~2.13",
7381
"less": "~4.4",
82+
"mocha": "~11.7",
7483
"replacer-util": "~1.5",
7584
"rev-web-assets": "~1.5",
7685
"rimraf": "~6.1",

spec/web.spec.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Snap Backup
2+
// Mocha Specification Suite
3+
4+
// Imports
5+
import { assertDeepStrictEqual } from 'assert-deep-strict-equal';
6+
import { revWebAssets } from 'rev-web-assets';
7+
import fs from 'fs';
8+
9+
////////////////////////////////////////////////////////////////////////////////
10+
describe('The website root folder', () => {
11+
12+
it('contains the correct files', () => {
13+
const actual = fs.readdirSync('website-target/3-prod').map(revWebAssets.stripHash).sort();
14+
const expected = [
15+
'about',
16+
'app',
17+
'app.min.js',
18+
'download',
19+
'faq',
20+
'graphics',
21+
'index.html',
22+
'screen',
23+
'snap-backup-user-guide.html',
24+
'style.css',
25+
'translate',
26+
'version',
27+
];
28+
assertDeepStrictEqual(actual, expected);
29+
});
30+
31+
});

tools/build-website.sh.command

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ publishWebFiles() {
5454
publishFolder=$publishSite/www.snapbackup.org
5555
publish() {
5656
echo "Publishing:"
57-
echo $publishSite
58-
mkdir -pv $publishFolder
59-
cp -R website-target/3-rev/* $publishFolder
60-
ls -o $publishSite | grep snapbackup
57+
rm -r $publishFolder
58+
mkdir -v $publishFolder
59+
cp -R website-target/3-prod/* $publishFolder
60+
cp $publishSite/files/resources/404-source.html $publishFolder/404.html
61+
ls -p $publishFolder | grep --invert-match /
6162
test -x "$(which tree)" && tree $publishFolder
6263
}
6364
test -w $publishSite && publish

website/root/download/index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ <h2>Download</h2>
4040
</div>
4141
<br>
4242
<p class=for-macs-only>
43-
For other operating systems: <a href="./?view=all">All Downloads</a>
43+
For other operating systems:
44+
<a href="./?view=all" class=indent>All Downloads</a>
4445
</p>
4546
<div class=for-non-macs>
4647
<figure class=cake-layers>
@@ -92,8 +93,9 @@ <h2>Download</h2>
9293
</div>
9394
</figure>
9495
</div>
95-
<p>
96-
For older releases: <a href={{releaseUrl}}/archive class=external-site>Past Releases</a>
96+
<p class=external-site>
97+
For older releases:
98+
<a href={{releaseUrl}}/archive class=indent>Past Releases</a>
9799
</p>
98100
<aside>
99101
<b>Languages Included:</b>
@@ -120,7 +122,7 @@ <h3>Getting started</h3>
120122
</p>
121123
<p>
122124
If you have a question, feel free create an issue and ask it:
123-
<a href=https://github.com/snap-backup/snapbackup/issues class=indent>New issue</a>.
125+
<a href=https://github.com/snap-backup/snapbackup/issues class=indent>New issue</a>
124126
</p>
125127
</section>
126128

website/root/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ <h3>Snap Backup:</h3>
5252

5353
<section>
5454
<h2>News</h2>
55-
<div>
55+
<div class=newsstand>
5656
{% render 'website/templates/news.html' %}
5757
</div>
5858
</section>

website/snap-backup.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
const app = {
44
setup() {
5-
const wedge = globalThis.document.createElement('div');
6-
wedge.classList.add('wedge');
7-
globalThis.document.querySelector('main').prepend(wedge);
85
const params = new URLSearchParams(globalThis.location.search);
96
const macosMode = libX.browser.macOS() && params.get('view') !== 'all';
107
dna.dom.toggleClass(globalThis.document.body, 'macos-mode', macosMode);

website/snap-backup.less

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
// Layout
77
body {
88
margin: 0px;
9-
>header, main, body >footer {
9+
>header,
10+
main,
11+
>footer {
1012
max-width: 800px;
1113
margin: 0px;
1214
}
@@ -16,46 +18,39 @@ body {
1618
body {
1719
>header {
1820
padding-top: 30px;
19-
margin-bottom: 20px;
21+
margin-bottom: 40px;
22+
.arch {
23+
position: absolute;
24+
top: 0px;
25+
left: 145px; //set to "width" of "nav.hamburger-menu aside" minus 5px
26+
width: calc(100% - 145px); //match px of "left"
27+
background-color: palegreen;
28+
z-index: -1000;
29+
>div {
30+
height: 200px;
31+
background-color: white; .DarkMode({ background-color: @colorCharcoal; });
32+
border: 4px solid teal;
33+
border-right: none;
34+
border-bottom: none;
35+
border-top-left-radius: 1000px;
36+
}
37+
}
38+
>h1 {
39+
font-size: 3rem;
40+
text-align: right;
41+
}
42+
>aside {
43+
padding-top: 15px;
44+
a img {
45+
height: 96px;
46+
}
47+
}
2048
}
2149
}
22-
body >header .arch {
23-
position: absolute;
24-
top: 0px;
25-
left: 145px; //set to "width" of "nav.hamburger-menu aside" minus 5px
26-
width: calc(100% - 145px); //match px of "left"
27-
background-color: palegreen;
28-
z-index: -1000;
29-
}
30-
body >header .arch >div {
31-
height: 200px;
32-
background-color: white; .DarkMode({ background-color: @colorCharcoal; });
33-
border: 4px solid teal;
34-
border-right: none;
35-
border-bottom: none;
36-
border-top-left-radius: 1000px;
37-
}
38-
body >header >h1 {
39-
font-size: 3rem;
40-
text-align: right;
41-
}
42-
body >header >aside {
43-
padding-top: 15px;
44-
}
45-
body >header >aside a img {
46-
height: 96px;
47-
}
4850

4951
// Main
50-
main >.wedge {
51-
float: left;
52-
width: 30px;
53-
height: 60px;
54-
shape-outside: polygon(0px 0px, 30px 0px, 0px 60px);
55-
}
56-
main >section:first-child >p:first-child,
57-
main >section:first-child >h2:first-child {
58-
text-indent: 2em;
52+
main {
53+
padding-bottom: 30px;
5954
}
6055
main >section >nav a {
6156
font-size: 0.9rem;
@@ -82,6 +77,11 @@ main >section aside {
8277
main >section >aside figure {
8378
max-width: 200px;
8479
}
80+
main >section .indent {
81+
display: block;
82+
width: fit-content;
83+
margin-left: 35px;
84+
}
8585
main >section figure.cake-layers {
8686
text-align: center;
8787
border: 1px solid darkgray;
@@ -125,6 +125,9 @@ main >section .screenshot-icons+figure figcaption {
125125
font-size: 1.2rem;
126126
font-weight: bold;
127127
}
128+
main >section div.newsstand p {
129+
margin-bottom: 12px;
130+
}
128131

129132
// Footer
130133
body >footer {
@@ -196,10 +199,10 @@ nav.hamburger-menu aside menu li >a:hover {
196199
body >header >h1 {
197200
font-size: 1.6rem;
198201
}
199-
body main >section h2 {
202+
body >main >section h2 {
200203
font-size: 1.3rem;
201204
}
202-
body main >section .indent {
205+
body >main >section .indent {
203206
margin-left: 20px;
204207
}
205208
});

website/templates/news.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class=news>
1+
<div>
22
<div>
33
<cite>December 11, 2024</cite>
44
<p>Snap Backup release 6.7.0 improves the Italian translation thanks to
@@ -84,7 +84,7 @@
8484
<div>
8585
<cite>April 12, 2007</cite>
8686
<p>Snap Backup is now open source under the GNU General Public
87-
License.&nbsp; The project <del>is</del> <i>was</i> hosted on Google Code.</p>
87+
License.&nbsp; The project is hosted on Google Code.</p>
8888
</div>
8989
<div>
9090
<cite>June 9, 2006</cite>

0 commit comments

Comments
 (0)