Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap version updated to remove jQuery dependency #1235

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 29 additions & 48 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@
"dependencies": {
"@fortawesome/fontawesome-free": "5.9.0",
"@types/fs-extra": "^9.0.11",
"bootstrap": "^4.6.2",
"core-js": "3.30.2",
"jquery": "^3.7.0"
"bootstrap": "^5.0.2",
"core-js": "3.30.2"
},
"devDependencies": {
"@babel/cli": "^7.21.5",
Expand Down
37 changes: 18 additions & 19 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ const config = {
copy({
targets: [{
src: ['www/js/lib/*dec-wasm.wasm', 'www/js/lib/libzim-asm.js', 'www/js/lib/libzim-wasm.*', 'www/js/lib/webpHeroBundle*',
'node_modules/bootstrap/dist/js/bootstrap.bundle.min.*', 'node_modules/jquery/dist/jquery.slim.min.*', '!www/js/lib/libzim-wasm.dev*'],
'node_modules/bootstrap/dist/js/bootstrap.bundle.min.*',
'!www/js/lib/libzim-wasm.dev*'],
dest: 'dist/www/js'
},
{ src: ['node_modules/bootstrap/dist/css/bootstrap.min.*'], dest: 'dist/www/css' },
Expand Down Expand Up @@ -74,18 +75,18 @@ if (process.env.BUILD === 'production') {
transform: async (contents, filename) => {
const result = await minify(
contents.toString()
// Replace the entry point with the bundle
// Replace the entry point with the bundle
.replace(/(www[\\/]js[\\/])app.js/, '$1bundle.min.js')
// Remove all the lib files that will be included in the bundle
// Remove all the lib files that will be included in the bundle
.replace(/,\s+["']www[\\/]js[\\/]lib[\\/]abstractFilesystemAccess[\s\S]+zimfile.js["']\s*/, '')
// Replace any references to node_modules
// Replace any references to node_modules
.replace(/node_modules\/.*dist\/((?:js|css)\/)?/g, function (m, p1) {
p1 = p1 || 'js/';
return 'www/' + p1;
})
// Alter remaining lib references
// Alter remaining lib references
.replace(/([\\/])js[\\/]lib/g, '$1js')
// Remove unneeded ASM/WASM binaries
// Remove unneeded ASM/WASM binaries
.replace(/["']www[\\/]js[\\/].*dec.*js["'],\s*/g, '')
);
return result.code;
Expand Down Expand Up @@ -125,13 +126,12 @@ if (process.env.BUILD === 'production') {
dest: 'dist/www',
// Link the html to the new bundle entry point
transform: (contents, filename) => contents.toString()
// Uncomment the bundle link
// Uncomment the bundle link
.replace(/<!--\s(<script type="text\/javascript.*bundle.js.*)\s-->/, '$1')
.replace(/bundle\.js/, 'bundle.min.js')
// Comment out the old app.js link
// Comment out the old app.js link
.replace(/(<script type="module.*app.js.*)/, '<!-- $1 -->')
// Redirect jQuery and bootstrap
.replace(/(<script\s.*src=").*jquery.slim.min.js/, '$1js/jquery.slim.min.js')
// Redirect jQuery and bootstrap
.replace(/(<script\s.*src=").*bootstrap.bundle.min.js/, '$1js/bootstrap.bundle.min.js')
.replace(/(<link\s.*href=").*bootstrap.min.css/, '$1css/bootstrap.min.css')
}
Expand All @@ -156,18 +156,18 @@ if (process.env.BUILD === 'production') {
dest: 'dist',
// Modify the Service Worker precache files
transform: (contents, filename) => contents.toString()
// Replace the entry point with the bundle
// Replace the entry point with the bundle
.replace(/(www\/js\/)app.js/, '$1bundle.js')
// Remove all the lib files that will be included in the bundle
// Remove all the lib files that will be included in the bundle
.replace(/,\s+["']www\/js\/lib\/abstractFilesystemAccess[\s\S]+zimfile.js["']/, '')
// Replace any references to node_modules
// Replace any references to node_modules
.replace(/node_modules\/.*dist\/((?:js|css)\/)?/g, function (m, p1) {
p1 = p1 || 'js/';
return 'www/' + p1;
})
// Alter remaining lib references
// Alter remaining lib references
.replace(/([\\/])js[\\/]lib/g, '$1js')
// Remove unneeded ASM/WASM binaries
// Remove unneeded ASM/WASM binaries
.replace(/['"]www[\\/]js[\\/].*dec.*js['"],\s*/g, '')
},
{
Expand All @@ -179,12 +179,11 @@ if (process.env.BUILD === 'production') {
dest: 'dist/www',
// Link the html to the new bundle entry point
transform: (contents, filename) => contents.toString()
// Uncomment the bundle link
// Uncomment the bundle link
.replace(/<!--\s(<script type="text\/javascript.*bundle.js.*)\s-->/, '$1')
// Comment out the old app.js link
// Comment out the old app.js link
.replace(/(<script type="module.*app.js.*)/, '<!-- $1 -->')
// Redirect jQuery and bootstrap
.replace(/(<script\s.*src=").*jquery.slim.min.js/, '$1js/jquery.slim.min.js')
// Redirect jQuery and bootstrap
.replace(/(<script\s.*src=").*bootstrap.bundle.min.js/, '$1js/bootstrap.bundle.min.js')
.replace(/(<link\s.*href=").*bootstrap.min.css/, '$1css/bootstrap.min.css')
}
Expand Down
4 changes: 1 addition & 3 deletions scripts/Check-OfflineFilesList.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ $ListOfExemptions = (
'www/js/lib/webpHeroBundle_0.0.2.js',
'www/js/lib/libzim-asm.dev.js',
'www/js/lib/libzim-wasm.dev.js',
'www/js/lib/libzim-wasm.dev.wasm',
'www/js/lib/jquery-3.7.0.slim.js',
'www/js/lib/jquery-3.7.0.slim.min.map'
'www/js/lib/libzim-wasm.dev.wasm'
)

# Get the absolute root directory
Expand Down
5 changes: 0 additions & 5 deletions scripts/patch_gitignore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,4 @@ sed -i 's|/node_modules\*/|/node_modules/*\
!/node_modules/bootstrap/dist/js\
/node_modules/bootstrap/dist/js/*\
!/node_modules/bootstrap/dist/js/bootstrap.bundle.min.*\
!/node_modules/jquery\
/node_modules/jquery/*\
!/node_modules/jquery/dist\
/node_modules/jquery/dist/*\
!/node_modules/jquery/dist/jquery.slim.min.*\
|' .gitignore
6 changes: 2 additions & 4 deletions service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ const precacheFiles = [
'node_modules/bootstrap/dist/js/bootstrap.bundle.min.js',
'node_modules/bootstrap/dist/js/bootstrap.bundle.min.js.map',
'node_modules/bootstrap/dist/css/bootstrap.min.css',
'node_modules/bootstrap/dist/css/bootstrap.min.css.map',
'node_modules/jquery/dist/jquery.slim.min.js',
'node_modules/jquery/dist/jquery.slim.min.map'
'node_modules/bootstrap/dist/css/bootstrap.min.css.map'
];

if ('WebAssembly' in self) {
Expand Down Expand Up @@ -470,7 +468,7 @@ function zimitResolver (event) {
}
});
});
// Check that the requested URL is for a ZIM that we already have loaded
// Check that the requested URL is for a ZIM that we already have loaded
} else if (zimStem !== rqUrl && isReplayWorkerAvailable) {
// Wait for the ReplayWorker to initialize and reload all collections
return replayCollectionsReloaded.then(function () {
Expand Down
8 changes: 8 additions & 0 deletions www/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,14 @@ button {
margin: 2px;
}

/* Changes - overriding changes of bootstrap for dark btn hover*/

.btn-outline-dark:hover {
color: #fff;
background-color: #6c757d;
border-color: #6c757d;
}

.btn-danger {
background-color: lightyellow;
color: darkred;
Expand Down
Loading
Loading