Skip to content

Commit

Permalink
Merge 07a10dd into 868ef30
Browse files Browse the repository at this point in the history
  • Loading branch information
heho authored Apr 17, 2023
2 parents 868ef30 + 07a10dd commit 2e504fa
Show file tree
Hide file tree
Showing 23 changed files with 1,249 additions and 411 deletions.
7 changes: 6 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
THEME_PRIMARY="#d32228"
THEME_PRIMARY_DARK="#7e1317"
THEME_PRIMARY_LIGHT="#ed4047"
THEME_PRIMARY_LIGHT="#ed4047"
THEME_NEUTRAL="#323130"
THEME_NEUTRAL_LIGHT="#656462"
THEME_NEUTRAL_DARK="#1F1E1D"
SETTINGS_INFORMATION="<h2>BAAT</h2><div>Bookmarklet Accessibility Audit Tool v@VERSION@</div><p>BAAT is a tool for running automatic accessibility testing scripts directly in the browser and inspecting the results.</p><p>You can find the documentation on the <a href='https://github.com/mindscreen/baat'>BAAT GitHub Page</a>.</p>"
AXE_MIN_URL="https://cdn.jsdelivr.net/npm/axe-core/axe.min.js"
12 changes: 11 additions & 1 deletion .github/workflows/npm-gulp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
asset_path: ./bookmarklet.txt
asset_name: bookmarklet.txt
asset_content_type: text/plain
- name: Upload bookmarklet
- name: Upload Userscript
id: upload-userscript
uses: actions/upload-release-asset@v1
env:
Expand All @@ -87,3 +87,13 @@ jobs:
asset_path: ./userscript.js
asset_name: userscript.js
asset_content_type: text/javascript
- name: Upload Bookmark Export
id: upload-bookmark-export
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./baat-bookmark.html
asset_name: baat-bookmark.html
asset_content_type: text/html
3 changes: 3 additions & 0 deletions extras/bookmark-export-footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
" ADD_DATE="{timestamp}">BAAT</A>
</DL><p>
</DL><p>
11 changes: 11 additions & 0 deletions extras/bookmark-export-header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 ADD_DATE="1633626970" LAST_MODIFIED="1680519255" PERSONAL_TOOLBAR_FOLDER="true">Bookmarks bar</H3>
<DL><p>
<DT><A ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAC+klEQVR4AayVA7ilXBhGv2vjt23btm3btm1zbNu2bds2w0ZnDToaXj4r17uqTbm7glSOIPiKNygsS4xcnuePuGDTTMeqdTxa6vhd3krHuOuiAjIDczGv4xvzEyklx4MPjfkwcjzAgaHgaNgP4WI2av13SXHzuWeuR0glCLggFFxsghQE4Vx8w0t3C9lcyXN8yz/U2MrffMOzXE7W3cL9xl6NbGeNx+2h4CpPCyH3EgTuaKuVmel09RvabflGtps/y1HWKneI1S8iUZa53BsKLlcmvJRPMzyqcxkZyE5kcgU1UTQiL3plpcddoeBEKERIoSvjOBbZCycwibYIQgom4OJQkBWYixEeYg2HIiVwJOu5GyFRC1vZPOFDhFb8iSCcxmAcRnMfEuUJxuHQlxMRhGo0QngOZ1G8IfHhNE+YziMIWcykHpfyGQ7vIAjfsoH3uZSmTCYD4WkmIAz0g18SgoOMfwczeAjhQiaShSDchksRh6C5AkHIZSpnIzzJBC4lsByb1JmCb5brzzkBSSIXhyIOZDPpSBKn8AGztP5/h97InV5kWKQISYaM+DaZHHpE/Ah3JAlIc2f/FhnBDC5ESuB0xjKZKhF3BqkJwb0bVQHZ/I+hOZeRuofw+dRD04ACinEUt8cFqkVtGz5yNs1QLKUZH/E0d3Apl3A7T/I+jVmApR2XRGWNjGoUFZCiN9+GxCniQf6iFxNYjIfPEibSl/94jP2QOHejNsQEh8GhSBk5CuCAUHCFMillFqQl9YXbVnlC2dngc2MouHWzqWsnOCPcb9kPKYED+IGR7ninVuCamOAWs0I34TXe9yauVWche+F8Nmh3LO/yhm5mVsYE6fHRNkVXX6GKkT2wH2uV+StpdM7YZWIh3Zv4vz2RZnqDv9r/w2aTzZ92tb/Bb6qPp5Zxx5BawszErcoq43XhZu7xFrTXnbQ3n7u5xevmG2O5ocSpjdRgKs9Fj481m/RGtkwBykv7ewWz3sBW73Aj10H/vZB4PDSpXCmEABekxWTM//65AAAAAElFTkSuQmCC" HREF="javascript:/*BAAT v{baat.version}*/
29 changes: 29 additions & 0 deletions gulp/UrlEncode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use strict";
const Transform = require("stream").Transform;

function encodeRFC3986URIComponent(str) {
return encodeURIComponent(str).replace(
/[!'()*]/g,
(c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`,
);
}

const URLEncoder = () => {
return new Transform({
readableObjectMode: true,
writableObjectMode: true,

transform: function (chunk, encoding, callback) {
if (chunk.isNull()) {
return callback(null, chunk);
}
const content = String(chunk.contents)

chunk.contents = Buffer.from(encodeRFC3986URIComponent(content));

callback(null, chunk);
},
});
}

module.exports = URLEncoder;
50 changes: 45 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ const {nodeResolve} = require('@rollup/plugin-node-resolve')
const externalGlobals = require("rollup-plugin-external-globals")
const { default: minifyHTML } = require('rollup-plugin-minify-html-literals')
const header = require('gulp-header')
const footer = require('gulp-footer')
const pkg = require('./package.json')
const fs = require('fs')
const browserSync = require('browser-sync').create()
const sourcemaps = require('gulp-sourcemaps')
const path = require('path')
const replace = require('gulp-replace');
const dotenv = require('dotenv');
const URLEncoder = require("./gulp/UrlEncode");

dotenv.config();

Expand All @@ -39,6 +41,7 @@ gulp.task('serve:reload' , function(cb) {

gulp.task('transpile-ts', function () {
return tsProject.src()
.pipe(replace('@INFORMATION@', String(process.env.SETTINGS_INFORMATION) !== "" ? String(process.env.SETTINGS_INFORMATION) : "false"))
.pipe(sourcemaps.init())
.pipe(tsProject())
.pipe(sourcemaps.write({
Expand All @@ -47,10 +50,14 @@ gulp.task('transpile-ts', function () {
return path.relative(path.dirname(file.path), file.base);
}
}))
.pipe(replace('@VERSION@', String(process.env.PACKAGE_VERSION)))
.pipe(replace('@PRIMARY@', String(process.env.THEME_PRIMARY)))
.pipe(replace('@PRIMARY_LIGHT@', String(process.env.THEME_PRIMARY_LIGHT)))
.pipe(replace('@PRIMARY_DARK@', String(process.env.THEME_PRIMARY_DARK)))
.pipe(replace('@VERSION@', String(process.env.npm_package_version)))
.pipe(replace('@AXE_MIN_URL@', String(process.env.AXE_MIN_URL)))
.pipe(replace('@PRIMARY@', String(process.env.THEME_PRIMARY) !== "" ? String(process.env.THEME_PRIMARY) : "#d32228"))
.pipe(replace('@PRIMARY_LIGHT@', String(process.env.THEME_PRIMARY_LIGHT) !== "" ? String(process.env.THEME_PRIMARY_LIGHT) : "#7e1317"))
.pipe(replace('@PRIMARY_DARK@', String(process.env.THEME_PRIMARY_DARK) !== "" ? String(process.env.THEME_PRIMARY_DARK) : "#ed4047"))
.pipe(replace('@THEME_NEUTRAL@', String(process.env.THEME_NEUTRAL) !== "" ? String(process.env.THEME_NEUTRAL) : "#323130"))
.pipe(replace('@THEME_NEUTRAL_LIGHT@', String(process.env.THEME_NEUTRAL_LIGHT) !== "" ? String(process.env.THEME_NEUTRAL_LIGHT) : "#656462"))
.pipe(replace('@THEME_NEUTRAL_DARK@', String(process.env.THEME_NEUTRAL_DARK) !== "" ? String(process.env.THEME_NEUTRAL_DARK) : "#1F1E1D"))
.pipe(gulp.dest('intermediate'))
})

Expand Down Expand Up @@ -108,8 +115,41 @@ gulp.task('rollup-bookmarklet', function () {
.pipe(header(fs.readFileSync('extras/bookmarklet-header.txt', 'utf8').replace('{baat.version}',pkg.version), {version: pkg.version}))
.pipe(gulp.dest('./build/'));
});

gulp.task('rollup-bookmark-export', function () {
return gulp.src([
'./intermediate/src/index.js',
])
.pipe(gru2.rollup({
input: './intermediate/src/index.js',
plugins: [
nodeResolve(),
minifyHTML(),
externalGlobals({
'axe-core': 'axe',
}),
],
external: [
'axe-core',
],
output: [
{
file: 'baat-bookmark.html',
name: 'baat',
format: 'iife',
},
],
}))
.pipe(uglify({compress: { negate_iife: false }}))
.pipe(URLEncoder())
.pipe(header(fs.readFileSync('extras/bookmark-export-header.html', 'utf8').replace('{baat.version}', pkg.version), {version: pkg.version}))
.pipe(footer(fs.readFileSync('extras/bookmark-export-footer.html', 'utf8').replace('{timestamp}', String(Math.round((new Date()).getTime()/1000))), {version: pkg.version}))
.pipe(gulp.dest('./build/'));
})
gulp.task('build.bookmarklet', gulp.series('transpile-ts', 'rollup-bookmarklet'));

gulp.task('build.userscript', gulp.series('transpile-ts', 'rollup-userscript'));

gulp.task('default', gulp.series('transpile-ts', 'rollup-bookmarklet', 'rollup-userscript'));
gulp.task('build.bookmark-export', gulp.series('transpile-ts', 'rollup-bookmark-export'));

gulp.task('default', gulp.series('transpile-ts', 'rollup-bookmarklet', 'rollup-userscript', 'rollup-bookmark-export'));
Loading

0 comments on commit 2e504fa

Please sign in to comment.