Skip to content

Commit

Permalink
feat: cookie consent, closes #46
Browse files Browse the repository at this point in the history
html pages for cookie consent
move ga.js to html dir and add a comment about setting it up
new gulp task and npm script for minifying cookie js & opening to the admin setting
  • Loading branch information
phette23 committed Sep 30, 2024
1 parent 860c7a2 commit 65f91d3
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 2 deletions.
15 changes: 13 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ function catalogJS () {
.pipe(dest('dist'))
}

function cookieConsentedJS() {
return src('html/CookieConsentedJS.js')
.pipe(concat('CookieConsentedJS.js'))
.pipe(iife())
.pipe(babel({ presets: ['@babel/preset-env'] }))
.pipe(uglify())
.pipe(insert.prepend(`// minified ${Date()} - see https://github.com/cca/koha_snippets\n`))
.pipe(dest('dist'))
}

function adminCSS() {
return src('admin-scss/index.scss')
.pipe(sass(sassOpts).on('error', sass.logError))
Expand All @@ -50,7 +60,7 @@ function catalogCSS() {
}

function lint() {
return src(['admin-js/*.js', 'catalog-js/*.js'])
return src(['admin-js/*.js', 'catalog-js/*.js', 'html/*.js'])
.pipe(eslint())
.pipe(eslint.format())
}
Expand All @@ -64,9 +74,10 @@ function stylelint() {
module.exports = {
'admin-js': adminJS,
'catalog-js': catalogJS,
'cookie-js': cookieConsentedJS,
'admin-css': adminCSS,
'catalog-css': catalogCSS,
js: parallel(adminJS, catalogJS),
js: parallel(adminJS, catalogJS, cookieConsentedJS),
css: parallel(catalogCSS, adminCSS),
default: parallel(adminJS, catalogJS, adminCSS, catalogCSS),
lint: lint,
Expand Down
1 change: 1 addition & 0 deletions html/CookieConsentBar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>The online catalog uses functional cookies: these are essential to make the site work.</p>
67 changes: 67 additions & 0 deletions html/CookieConsentPopup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<h3>What are cookies?</h3>
<p>Cookies are small text files placed on your browser by websites. They help make websites work, or work more efficiently. They also "remember" some of your preferences, so you don't have to set a preference again every time you switch to a different page on the same website.</p>
<p>If cookies are a concern for you, you may like to regularly clear your cookies on your browser or use a private browser mode. Check your browser settings for these options.</p>
<h3>Essential cookies</h3>
<p>Here is the list of essential cookies used on the Koha online catalog.</p>
<p>Some of these depend on settings chosen by the library team; therefore all the cookies listed may not apply to this site.</p>
<table id="cookiesinfot" class="table table-bordered table-striped">
<thead>
<tr>
<th>Storage</th>
<th>Name</th>
<th>Value</th>
<th>Expiration</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cookie</td>
<td>CGISESSID</td>
<td>Session ID</td>
<td>Until logout or end of session</td>
<td>Session cookie</td>
</tr>
<tr>
<td>Cookie</td>
<td>KohaOpacLanguage</td>
<td>Language code</td>
<td>3 years</td>
<td>Stores the language the user selected, so the online catalog will appear in that same language the next time it is visited.</td>
</tr>
<tr>
<td>Cookie</td>
<td>
<p>form_serialized</p>
<p>form_serialized_limits</p>
</td>
<td>Search terms and limits</td>
<td>End of session or when the advanced search page is accessed again.</td>
<td>jQuery cookie. Stores search terms and limits of the last advanced search. Set when an advanced search is submitted.</td>
</tr>
<tr>
<td>Cookie</td>
<td>search_path_code</td>
<td>ads (fewer) or exs (more)</td>
<td>End of session or when the advanced search page is accessed again.</td>
<td>jQuery cookie. Related to serialized_form* cookies. Stores if the advanced search form was used with 'More options' or 'Fewer options'.</td>
</tr>
<tr>
<td>Cookie</td>
<td>num_paragraph</td>
<td>Count of search options added</td>
<td>End of session or when the advanced search page is accessed again.</td>
<td>jQuery cookie. Used to store the number of created options when user selects 'More options' in advanced search to increase search boxes.</td>
</tr>
<tr>
<td>Cookie</td>
<td>bib_list</td>
<td>List of record IDs (biblionumbers) separated by /</td>
<td>End of session or until the cart is emptied.</td>
<td>Stores cart contents in the online catalog. Set when records are added to the cart for the first time.</td>
</tr>
</tbody>
</table>
<h3>Non-essential cookies</h3>
<p>The library team may create additional cookies. These are optional and will require your agreement before they are used.</p>
<p>If any non-essential cookies are created, they will appear below.</p>
2 changes: 2 additions & 0 deletions catalog-js/ga.js → html/CookieConsentedJS.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// This file is added to Patrons Preferences > Privacy > CookieConsentedJS
// as our "Google Analytics" cookie, string=_ga | domain=cca.edu | path=/
// load google tags analytics library
let d = document
, s = d.createElement('script')
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"acss": "gulp admin-css && cat dist/IntranetUserCSS.css | pbcopy && open 'https://library-staff.cca.edu/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=IntranetUserCSS'",
"cjs": "gulp catalog-js && cat dist/OPACUserJS.js | pbcopy && open 'https://library-staff.cca.edu/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=OPACUserJS'",
"ccss": "gulp catalog-css && cat dist/OPACUserCSS.css | pbcopy && open 'https://library-staff.cca.edu/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=OPACUserCSS'",
"cookiejs": "gulp cookie-js && cat dist/CookieConsentedJS.js | pbcopy && open 'https://library-staff.cca.edu/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=CookieConsentedJS'",
"test": "gulp lint; stylelint --cache --fix **/*.scss 2>/dev/null; "
},
"author": "phette23 <phette23@gmail.com> (http://phette.net)",
Expand Down

0 comments on commit 65f91d3

Please sign in to comment.