Skip to content

Commit 16fa4f9

Browse files
authored
Merge branch 'internetarchive:master' into 10196/refactor/enable-ruff-rule-SIM115
2 parents 1ff3e14 + 16fb67e commit 16fa4f9

40 files changed

+488
-128
lines changed

.github/workflows/olbase.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,22 @@ jobs:
2828
username: ${{ secrets.DOCKERHUB_USERNAME }}
2929
password: ${{ secrets.DOCKERHUB_TOKEN }}
3030

31-
- name: Build and push
31+
# If on master, use the latest tag, otherwise use the branch name
32+
- name: Master Build and push
3233
uses: docker/build-push-action@v6
34+
if: github.ref == 'refs/heads/master'
3335
with:
3436
context: "."
3537
file: "./docker/Dockerfile.olbase"
3638
tags: openlibrary/olbase:latest
3739
push: true
40+
41+
# If on another branch, use the branch name -- just the branch name, not the full ref
42+
- name: Test Branch Build and push
43+
uses: docker/build-push-action@v6
44+
if: github.ref != 'refs/heads/master'
45+
with:
46+
context: "."
47+
file: "./docker/Dockerfile.olbase"
48+
tags: openlibrary/olbase:${{ github.ref_name }}
49+
push: true

compose.production.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ services:
126126
user: root
127127
command: docker/ol-cron-start.sh
128128
restart: unless-stopped
129-
env_file:
130-
- ../olsystem/etc/cron-jobs.env
131129
volumes:
132130
- ../olsystem/etc/cron.d/openlibrary.ol_home0:/etc/cron.d/openlibrary.ol_home0:ro
133131
- ../olsystem:/olsystem

openlibrary/components/IdentifiersInput.vue

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
</th>
2929
</tr>
3030
<template v-for="(value, name) in assignedIdentifiers">
31-
<tr :key="name" v-if="value && !isEdition">
31+
<tr :key="name" v-if="value && !saveIdentifiersAsList">
3232
<td>{{ identifierConfigsByKey[name].label }}</td>
3333
<td>{{ value }}</td>
3434
<td>
3535
<button class="form-control" @click="removeIdentifier(name)">Remove</button>
3636
</td>
3737
</tr>
38-
<template v-else-if="value && isEdition">
38+
<template v-else-if="value && saveIdentifiersAsList">
3939
<tr v-for="(item, idx) in value" :key="name + idx">
4040
<td>{{ identifierConfigsByKey[name].label }}</td>
4141
<td>{{ item }}</td>
@@ -52,7 +52,7 @@
5252
</template>
5353

5454
<script>
55-
import { errorDisplay, validateEditionIdentifiers } from './IdentifiersInput/utils/utils.js';
55+
import { errorDisplay, validateIdentifiers } from './IdentifiersInput/utils/utils.js';
5656
const identifierPatterns = {
5757
wikidata: /^Q[1-9]\d*$/i,
5858
isni: /^[0]{4} ?[0-9]{4} ?[0-9]{4} ?[0-9]{3}[0-9X]$/i,
@@ -76,7 +76,9 @@ export default {
7676
id_config_string: {
7777
type: String
7878
},
79-
/** see createHiddenInputs function for usage */
79+
/** see createHiddenInputs function for usage
80+
* #hiddenEditionIdentifiers, #hiddenWorkIdentifiers
81+
*/
8082
output_selector: {
8183
type: String
8284
},
@@ -108,20 +110,20 @@ export default {
108110
return {
109111
selectedIdentifier: '', // Which identifier is selected in dropdown
110112
inputValue: '', // What user put into input
111-
assignedIdentifiers: {}, // IDs assigned to the entity Ex: {'viaf': '12632978'}
113+
assignedIdentifiers: {}, // IDs assigned to the entity Ex: {'viaf': '12632978'} or {'abaa': ['123456','789012']}
112114
}
113115
},
114116
115117
computed: {
116118
popularEditionConfigs: function() {
117-
if (this.isEdition) {
119+
if (this.edition_popular) {
118120
const popularConfigs = JSON.parse(decodeURIComponent(this.edition_popular));
119121
return Object.fromEntries(popularConfigs.map(e => [e.name, e]));
120122
}
121123
return {};
122124
},
123125
secondaryEditionConfigs: function() {
124-
if (this.isEdition) {
126+
if (this.secondary_identifiers) {
125127
const secondConfigs = JSON.parse(decodeURIComponent(this.secondary_identifiers));
126128
return Object.fromEntries(secondConfigs.map(e => [e.name, e]));
127129
}
@@ -139,6 +141,9 @@ export default {
139141
return this.admin.toLowerCase() === 'true';
140142
},
141143
isEdition() {
144+
return this.multiple.toLowerCase() === 'true' && this.edition_popular;
145+
},
146+
saveIdentifiersAsList() {
142147
return this.multiple.toLowerCase() === 'true';
143148
},
144149
setButtonEnabled: function(){
@@ -154,10 +159,10 @@ export default {
154159
if (this.selectedIdentifier === 'isni') {
155160
this.inputValue = this.inputValue.replace(/\s/g, '')
156161
}
157-
if (this.isEdition) {
162+
if (this.saveIdentifiersAsList) {
158163
// collect id values of matching type, or empty array if none present
159164
const existingIds = this.assignedIdentifiers[this.selectedIdentifier] ?? [];
160-
const validEditionId = validateEditionIdentifiers(this.selectedIdentifier, this.inputValue, existingIds);
165+
const validEditionId = validateIdentifiers(this.selectedIdentifier, this.inputValue, existingIds, this.output_selector);
161166
if (validEditionId) {
162167
if (!this.assignedIdentifiers[this.selectedIdentifier]) {
163168
this.inputValue = [this.inputValue];
@@ -170,18 +175,18 @@ export default {
170175
return;
171176
}
172177
} else if (this.assignedIdentifiers[this.selectedIdentifier]) {
173-
errorDisplay(`An author identifier for ${this.identifierConfigsByKey[this.selectedIdentifier].label} already exists.`)
178+
errorDisplay(`An identifier for ${this.identifierConfigsByKey[this.selectedIdentifier].label} already exists.`, this.output_selector)
174179
return;
175-
} else { errorDisplay() }
180+
} else { errorDisplay('', this.output_selector) }
176181
// We use $set otherwise we wouldn't get the reactivity desired
177182
// See https://vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats
178183
this.$set(this.assignedIdentifiers, this.selectedIdentifier, this.inputValue);
179184
this.inputValue = '';
180185
this.selectedIdentifier = '';
181186
},
182187
/** Removes an identifier with value from memory and it will be deleted from database on save */
183-
removeIdentifier: function(identifierName, idx = 0){
184-
if (this.isEdition) {
188+
removeIdentifier: function(identifierName, idx = 0) {
189+
if (this.saveIdentifiersAsList) {
185190
this.assignedIdentifiers[identifierName].splice(idx, 1);
186191
} else {
187192
this.$set(this.assignedIdentifiers, identifierName, '');
@@ -194,7 +199,8 @@ export default {
194199
* So for now this just drops the hidden inputs into the the parent form anytime there is a change
195200
*/
196201
let html = '';
197-
if (this.isEdition) {
202+
// should save a list of ids for work + edition identifiers
203+
if (this.saveIdentifiersAsList) {
198204
let num = 0;
199205
for (const [key, value] of Object.entries(this.assignedIdentifiers)) {
200206
for (const idx in value) {
@@ -227,7 +233,11 @@ export default {
227233
},
228234
created: function(){
229235
this.assignedIdentifiers = JSON.parse(decodeURIComponent(this.assigned_ids_string));
230-
if (this.isEdition) {
236+
if (this.assignedIdentifiers.length === 0) {
237+
this.assignedIdentifiers = {}
238+
return;
239+
}
240+
if (this.saveIdentifiersAsList) {
231241
const edition_identifiers = {};
232242
this.assignedIdentifiers.forEach(entry => {
233243
if (!edition_identifiers[entry.name]) {

openlibrary/components/IdentifiersInput/utils/utils.js

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ import {
88
isValidLccn,
99
} from '../../../plugins/openlibrary/js/idValidation.js';
1010

11-
export function errorDisplay(message) {
12-
const errorSelector = document.querySelector('#id-errors');
11+
export function errorDisplay(message, error_output) {
12+
let errorSelector;
13+
if (error_output === '#hiddenAuthorIdentifiers') {
14+
errorSelector = document.querySelector('#id-errors-author')
15+
} else if (error_output === '#hiddenWorkIdentifiers') {
16+
errorSelector = document.querySelector('#id-errors-work')
17+
} else if (error_output === '#hiddenEditionIdentifiers') {
18+
errorSelector = document.querySelector('#id-errors-edition')
19+
}
1320
if (message) {
1421
errorSelector.style.display = '';
1522
errorSelector.innerHTML = `<div>${message}</div>`;
@@ -23,10 +30,12 @@ export function errorDisplay(message) {
2330
function validateIsbn10(value) {
2431
const isbn10_value = parseIsbn(value);
2532
if (!isFormatValidIsbn10(isbn10_value)) {
26-
errorDisplay('ID must be exactly 10 characters [0-9] or X.');
33+
errorDisplay('ID must be exactly 10 characters [0-9] or X.', '#hiddenEditionIdentifiers');
2734
return false;
28-
} else if (isFormatValidIsbn10(isbn10_value) === true && isChecksumValidIsbn10(isbn10_value) === false) {
29-
errorDisplay(`ISBN ${isbn10_value} may be invalid. Please confirm if you'd like to add it before saving all changes`);
35+
} else if (
36+
isFormatValidIsbn10(isbn10_value) && !isChecksumValidIsbn10(isbn10_value)
37+
) {
38+
errorDisplay(`ISBN ${isbn10_value} may be invalid. Please confirm if you'd like to add it before saving all changes`, '#hiddenEditionIdentifiers');
3039
}
3140
return true;
3241
}
@@ -35,10 +44,12 @@ function validateIsbn13(value) {
3544
const isbn13_value = parseIsbn(value);
3645

3746
if (!isFormatValidIsbn13(isbn13_value)) {
38-
errorDisplay('ID must be exactly 13 digits [0-9]. For example: 978-1-56619-909-4');
47+
errorDisplay('ID must be exactly 13 digits [0-9]. For example: 978-1-56619-909-4', '#hiddenEditionIdentifiers');
3948
return false;
40-
} else if (isFormatValidIsbn13(isbn13_value) === true && isChecksumValidIsbn13(isbn13_value) === false) {
41-
errorDisplay(`ISBN ${isbn13_value} may be invalid. Please confirm if you'd like to add it before saving all changes`);
49+
} else if (
50+
isFormatValidIsbn13(isbn13_value) && !isChecksumValidIsbn13(isbn13_value)
51+
) {
52+
errorDisplay(`ISBN ${isbn13_value} may be invalid. Please confirm if you'd like to add it before saving all changes`, '#hiddenEditionIdentifiers');
4253
}
4354
return true;
4455
}
@@ -47,18 +58,18 @@ function validateLccn(value) {
4758
const lccn_value = parseLccn(value);
4859

4960
if (!isValidLccn(lccn_value)) {
50-
errorDisplay('Invalid ID format');
61+
errorDisplay('Invalid ID format', '#hiddenEditionIdentifiers');
5162
return false;
5263
}
5364
return true;
5465
}
5566

56-
export function validateEditionIdentifiers(name, value, entries) {
67+
export function validateIdentifiers(name, value, entries, error_output) {
5768
let validId = true;
58-
errorDisplay('');
69+
errorDisplay('', error_output);
5970
if (name === '' || name === '---') {
6071
// if somehow an invalid identifier is passed through
61-
errorDisplay('Invalid identifier');
72+
errorDisplay('Invalid identifier', error_output);
6273
return false;
6374
}
6475
if (name === 'isbn_10') {
@@ -70,7 +81,7 @@ export function validateEditionIdentifiers(name, value, entries) {
7081
}
7182
if (Array.from(entries).some(entry => entry === value) === true) {
7283
validId = false;
73-
errorDisplay('That ID already exists for this edition');
84+
errorDisplay('That ID already exists for an identifier.', error_output);
7485
}
7586
return validId;
7687
}

openlibrary/components/LibraryExplorer.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
</template>
1616

1717
<script>
18-
import BookRoom from './LibraryExplorer/components/BookRoom';
19-
import LibraryToolbar from './LibraryExplorer/components/LibraryToolbar';
18+
import BookRoom from './LibraryExplorer/components/BookRoom.vue';
19+
import LibraryToolbar from './LibraryExplorer/components/LibraryToolbar.vue';
2020
import DDC from './LibraryExplorer/ddc.json';
2121
import LCC from './LibraryExplorer/lcc.json';
2222
import { recurForEach } from './LibraryExplorer/utils.js';

openlibrary/components/LibraryExplorer/components/BookCover3D.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
</template>
2323

2424
<script>
25-
import CSSBox from './CSSBox';
26-
import FlatBookCover from './FlatBookCover';
25+
import CSSBox from './CSSBox.vue';
26+
import FlatBookCover from './FlatBookCover.vue';
2727
import { hashCode } from '../utils.js';
2828
2929
export default {

openlibrary/components/LibraryExplorer/components/BooksCarousel.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</template>
2222

2323
<script>
24-
import FlatBookCover from './FlatBookCover';
24+
import FlatBookCover from './FlatBookCover.vue';
2525
import CONFIGS from '../../configs';
2626
2727
export default {

openlibrary/components/LibraryExplorer/components/Bookshelf.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</template>
1717

1818
<script>
19-
import Shelf from './Shelf';
19+
import Shelf from './Shelf.vue';
2020
2121
2222
export default {

openlibrary/components/LibraryExplorer/components/ClassSlider.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
</template>
2929

3030
<script>
31-
import RightArrowIcon from './icons/RightArrowIcon';
32-
import ShelfProgressBar from './ShelfProgressBar';
31+
import RightArrowIcon from './icons/RightArrowIcon.vue';
32+
import ShelfProgressBar from './ShelfProgressBar.vue';
3333
export default {
3434
components: { RightArrowIcon, ShelfProgressBar },
3535
props: {

openlibrary/components/LibraryExplorer/components/LibraryToolbar.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@
201201

202202
<script>
203203
import lucenerQueryParser from 'lucene-query-parser';
204-
import SettingsIcon from './icons/SettingsIcon';
205-
import FilterIcon from './icons/FilterIcon';
206-
import SortIcon from './icons/SortIcon';
207-
import FeedbackIcon from './icons/FeedbackIcon';
204+
import SettingsIcon from './icons/SettingsIcon.vue';
205+
import FilterIcon from './icons/FilterIcon.vue';
206+
import SortIcon from './icons/SortIcon.vue';
207+
import FeedbackIcon from './icons/FeedbackIcon.vue';
208208
import CONFIGS from '../../configs';
209209
import Multiselect from 'vue-multiselect';
210210

0 commit comments

Comments
 (0)