Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
Conflicts list below were resolved by keeping changes from main.
 Conflicts:
	concordia/static/js/src/asset-reservation.js
	concordia/static/js/src/contribute.js
	concordia/static/js/src/guide.js
	concordia/static/js/src/ocr.js
	concordia/static/js/src/quick-tips-setup.js
	concordia/static/js/src/viewer-split.js
	concordia/static/js/src/viewer.js
	concordia/templates/transcriptions/asset_detail.html
	concordia/templates/transcriptions/asset_detail/editor.html
	concordia/templates/transcriptions/asset_detail/ocr_transcription_modal.html
	concordia/templates/transcriptions/asset_detail/viewer_filters.html
  • Loading branch information
jkueloc committed Sep 9, 2024
2 parents d2a4c7b + 962273b commit 82b352b
Show file tree
Hide file tree
Showing 29 changed files with 1,534 additions and 679 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ env:
browser: true
es2024: true
parserOptions:
sourceType: script
sourceType: module
ecmaVersion: latest
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN apt-get update -qy && apt-get dist-upgrade -qy && apt-get install -o Dpkg::O
# Pillow/Imaging: https://pillow.readthedocs.io/en/latest/installation.html#external-libraries
libz-dev libfreetype6-dev \
libtiff-dev libjpeg-dev libopenjp2-7-dev libwebp-dev zlib1g-dev \
# Postgres client library to build psycopg2
# Postgres client library to build psycopg
libpq-dev \
locales \
# Weasyprint requirements
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ sentry-sdk = "*"
channels = {extras = ["daphne"], version = "*"}
channels-redis = ">=4"
more-itertools = "*"
psycopg2 = ">=2.9"
nh3 = "*"
django-admin-multiple-choice-list-filter = "*"
django-npm = "*"
Expand All @@ -55,6 +54,7 @@ pillow = "*"
prometheus-client = "*"
xlsxwriter = "*"
blinker = "<1.8.0"
psycopg2 = "*"

[dev-packages]
invoke = "*"
Expand Down
1,223 changes: 609 additions & 614 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion celerybeat/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN apt-get update -qy && apt-get dist-upgrade -qy && apt-get install -o Dpkg::O
# Pillow/Imaging: https://pillow.readthedocs.io/en/latest/installation.html#external-libraries
libz-dev libfreetype6-dev \
libtiff-dev libjpeg-dev libopenjp2-7-dev libwebp-dev zlib1g-dev \
# Postgres client library to build psycopg2
# Postgres client library to build psycopg
libpq-dev \
locales \
# Weasyprint requirements
Expand Down
4 changes: 2 additions & 2 deletions cloudformation/infrastructure/rds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ Resources:
AllocatedStorage: '20'
AllowMajorVersionUpgrade: false
AutoMinorVersionUpgrade: true
DBInstanceClass: db.t2.medium
DBInstanceClass: db.t4g.medium
Port: '5432'
PubliclyAccessible: false
StorageType: gp2
StorageType: gp3
StorageEncrypted: True
BackupRetentionPeriod: 31
MasterUsername: !Ref DbUsername
Expand Down
2 changes: 1 addition & 1 deletion concordia/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,9 +757,9 @@ class TranscriptionAdmin(admin.ModelAdmin):
"id",
"asset",
"user",
"campaign_slug",
"truncated_text",
"created_on",
"updated_on",
"accepted",
"rejected",
"reviewed_by",
Expand Down
3 changes: 3 additions & 0 deletions concordia/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,9 @@ class Meta:
def __str__(self):
return f"Transcription #{self.pk}"

def campaign_slug(self):
return self.asset.item.project.campaign.slug

def clean(self):
if (
self.user
Expand Down
27 changes: 24 additions & 3 deletions concordia/static/js/src/asset-reservation.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/* global jQuery displayMessage displayHtmlMessage buildErrorMessage Sentry */
/* exported attemptToReserveAsset */

const assetReservationData = document.getElementById(
'asset-reservation-data',
).dataset;

function attemptToReserveAsset(reservationURL, findANewPageURL, actionType) {
var $transcriptionEditor = jQuery('#transcription-editor');
let $transcriptionEditor = jQuery('#transcription-editor');

jQuery
.ajax({
Expand Down Expand Up @@ -75,7 +78,7 @@ function attemptToReserveAsset(reservationURL, findANewPageURL, actionType) {
});

window.addEventListener('beforeunload', function () {
var payload = {
let payload = {
release: true,
csrfmiddlewaretoken: jQuery(
'input[name="csrfmiddlewaretoken"]',
Expand All @@ -95,3 +98,21 @@ function attemptToReserveAsset(reservationURL, findANewPageURL, actionType) {
}
});
}

function reserveAssetForEditing() {
if (assetReservationData.reserveAssetUrl) {
attemptToReserveAsset(
assetReservationData.reserveAssetUrl,
'',
'transcribe',
);
}
}

jQuery(function () {
if (assetReservationData.reserveForEditing) {
reserveAssetForEditing();
}
});

export {reserveAssetForEditing};
22 changes: 11 additions & 11 deletions concordia/static/js/src/contribute.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* global $ displayMessage buildErrorMessage reserveAssetForEditing */
/* global $ displayMessage buildErrorMessage */

import {reserveAssetForEditing} from 'asset-reservation';

function lockControls($container) {
if (!$container) {
Expand All @@ -7,7 +9,7 @@ function lockControls($container) {
// Locks all of the controls in the provided jQuery element
$container.find('input, textarea').attr('readonly', 'readonly');
$container.find('input:checkbox').attr('disabled', 'disabled');
$container.find('button').attr('disabled', 'disabled');
$container.find('button:not(#open-guide)').attr('disabled', 'disabled');
}

function unlockControls($container) {
Expand All @@ -24,8 +26,6 @@ function unlockControls($container) {
// listener on the transcription form and the form
// results handlers.
// The only buttons unlocked here are ones that should always be unlocked.
// TODO: Find a better way to handle this than hard-coding every button
// we want to unlock here
$container.find('button#open-guide').removeAttr('disabled');
$container.find('button#ocr-transcription-button').removeAttr('disabled');
$container.find('button#close-guide').removeAttr('disabled');
Expand Down Expand Up @@ -121,11 +121,11 @@ function setupPage() {
$form.on('submit', function (event) {
event.preventDefault();

var data = $form.data();
var eventData = $form.data();

lockControls($form);
if (data.lockElement) {
lockControls($(data.lockElement));
if (eventData.lockElement) {
lockControls($(eventData.lockElement));
}

var formData = $form.serializeArray();
Expand All @@ -144,8 +144,8 @@ function setupPage() {
$form: $form,
});
unlockControls($form);
if (data.lockElement) {
unlockControls($(data.lockElement));
if (eventData.lockElement) {
unlockControls($(eventData.lockElement));
}
})
.fail(function (jqXHR, textStatus, errorThrown) {
Expand All @@ -167,8 +167,8 @@ function setupPage() {
jqXHR: jqXHR,
});
unlockControls($form);
if (data.lockElement) {
unlockControls($(data.lockElement));
if (eventData.lockElement) {
unlockControls($(eventData.lockElement));
}
}
});
Expand Down
85 changes: 85 additions & 0 deletions concordia/static/js/src/guide.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* global $ trackUIInteraction */

function openOffcanvas() {
let guide = document.getElementById('guide-sidebar');
if (guide.classList.contains('offscreen')) {
guide.classList.remove('offscreen');
guide.style.borderWidth = '0 0 thick thick';
guide.style.borderStyle = 'solid';
guide.style.borderColor = '#0076ad';
document.addEventListener('keydown', function (event) {
if (event.key == 'Escape') {
closeOffcanvas();
}
});
document.getElementById('open-guide').style.background = '#002347';
} else {
closeOffcanvas();
}
}

function closeOffcanvas() {
let guide = document.getElementById('guide-sidebar');
guide.classList.add('offscreen');
guide.style.border = 'none';

document.getElementById('open-guide').style.background = '#0076AD';
}

$('#open-guide').on('click', openOffcanvas);

$('#close-guide').on('click', closeOffcanvas);

$('#guide-carousel')
.carousel({
interval: false,
wrap: false,
})
.on('slide.bs.carousel', function (event) {
if (event.to == 0) {
$('#guide-bars').addClass('d-none');
} else {
$('#guide-bars').removeClass('d-none');
}
});

$('#previous-card').hide();

$('#card-carousel').on('slid.bs.carousel', function () {
if ($('#card-carousel .carousel-item:first').hasClass('active')) {
$('#previous-card').hide();
$('#next-card').show();
} else if ($('#card-carousel .carousel-item:last').hasClass('active')) {
$('#previous-card').show();
$('#next-card').hide();
} else {
$('#previous-card').show();
$('#next-card').show();
}
});

function trackHowToInteraction(element, label) {
trackUIInteraction(element, 'How To Guide', 'click', label);
}

$('#open-guide').on('click', function () {
trackHowToInteraction($(this), 'Open');
});
$('#close-guide').on('click', function () {
trackHowToInteraction($(this), 'Close');
});
$('#previous-guide').on('click', function () {
trackHowToInteraction($(this), 'Back');
});
$('#next-guide').on('click', function () {
trackHowToInteraction($(this), 'Next');
});
$('#guide-bars').on('click', function () {
trackHowToInteraction($(this), 'Hamburger Menu');
});
$('#guide-sidebar .nav-link').on('click', function () {
let label = $(this).text().trim();
trackHowToInteraction($(this), label);
});

export {openOffcanvas, closeOffcanvas};
21 changes: 21 additions & 0 deletions concordia/static/js/src/modules/quick-tips.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* global $ */

function setTutorialHeight() {
let $carouselItems = $('#card-carousel .carousel-item');
let heights = $carouselItems.map(function () {
let height = $(this).height();
if (height <= 0) {
let firstChild = $(this).children[0];
if (firstChild) {
height = firstChild.offsetHeight + 48;
} else {
return 517.195;
}
}
return height;
});
let maxHeight = Math.max.apply(this, heights);
$carouselItems.height(maxHeight);
}

export {setTutorialHeight};
8 changes: 8 additions & 0 deletions concordia/static/js/src/ocr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* global $ */

function selectLanguage() {
$('#ocr-transcription-modal').modal('hide');
$('#language-selection-modal').modal('show');
}

$('#select-language-button').on('click', selectLanguage);
46 changes: 46 additions & 0 deletions concordia/static/js/src/quick-tips-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* global $ trackUIInteraction */

import {setTutorialHeight} from './modules/quick-tips.js';

let mainContentHeight = $('#contribute-main-content').height();

if (mainContentHeight < 710) {
$('.sidebar').height(mainContentHeight - 130);
}

$('#tutorial-popup').on('shown.bs.modal', function () {
setTutorialHeight();
});

function trackQuickTipsInteraction(element, label) {
trackUIInteraction(element, 'Quick Tips', 'click', label);
}

$('#quick-tips').on('click', function () {
trackQuickTipsInteraction($(this), 'Open');
});

$('#previous-card').on('click', function () {
trackQuickTipsInteraction($(this), 'Back');
});

$('#next-card').on('click', function () {
trackQuickTipsInteraction($(this), 'Next');
});

$('.carousel-indicators li').on('click', function () {
let index = [...this.parentElement.children].indexOf(this);
trackQuickTipsInteraction($(this), `Carousel ${index}`);
});

$('#tutorial-popup').on('hidden.bs.modal', function () {
// We're tracking whenever the popup closes, so we don't separately track the close button being clicked
trackUIInteraction($(this), 'Quick Tips', 'click', 'Close');
});

$('#tutorial-popup').on('shown-on-load', function () {
// We set a timeout to make sure the analytics code is loaded before trying to track
setTimeout(function () {
trackUIInteraction($(this), 'Quick Tips', 'load', 'Open');
}, 1000);
});
Loading

0 comments on commit 82b352b

Please sign in to comment.