Skip to content

Commit

Permalink
Merge branch 'release/3.12.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
JackMorganNZ committed Oct 18, 2022
2 parents 485aa31 + 25260c2 commit d963c84
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 35 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/crowdin-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
uses: actions/checkout@v3

- name: Upload or update source files to Crowdin
uses: crowdin/github-action@1.4.14
uses: crowdin/github-action@1.4.15
with:
upload_sources: true

- name: Download German translations
uses: crowdin/github-action@1.4.14
uses: crowdin/github-action@1.4.15
with:
upload_sources: false
download_translations: true
Expand All @@ -42,7 +42,7 @@ jobs:
config: crowdin.yaml

- name: Download Spanish translations
uses: crowdin/github-action@1.4.14
uses: crowdin/github-action@1.4.15
with:
upload_sources: false
download_translations: true
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,14 @@ jobs:
ls artifacts/interactive-thumbnails-*/interactive-thumbnails.tar.gz | xargs -n1 tar -xz --directory csfieldguide/staticfiles/img/interactives/thumbnails --file
- name: Log in to ${{ env.REGISTRY }}
uses: docker/login-action@v2.0.0
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v3.1.1
uses: docker/build-push-action@v3.2.0
with:
file: ./infrastructure/production/django/Dockerfile
context: .
Expand Down Expand Up @@ -272,7 +272,7 @@ jobs:
ls artifacts/interactive-thumbnails-*/interactive-thumbnails.tar.gz | xargs -n1 tar -xz --directory csfieldguide/staticfiles/img/interactives/thumbnails --file
- name: Log in to ${{ env.REGISTRY }}
uses: docker/login-action@v2.0.0
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand All @@ -287,7 +287,7 @@ jobs:
type=ref,event=tag,enable=true
- name: Build and push Docker image
uses: docker/build-push-action@v3.1.1
uses: docker/build-push-action@v3.2.0
with:
file: ./infrastructure/production/django/Dockerfile
context: .
Expand Down
2 changes: 1 addition & 1 deletion csfieldguide/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Module for Django system configuration."""

__version__ = "3.12.0"
__version__ = "3.12.1"
6 changes: 3 additions & 3 deletions csfieldguide/package-lock.json

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

2 changes: 1 addition & 1 deletion csfieldguide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"multiple-select": "1.5.2",
"pixrem": "5.0.0",
"popper.js": "1.16.1",
"postcss": "8.4.17",
"postcss": "8.4.18",
"postcss-flexbugs-fixes": "5.0.2",
"sass": "1.55.0",
"vinyl-buffer": "1.0.1",
Expand Down
14 changes: 8 additions & 6 deletions csfieldguide/static/interactives/parity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ The interactive opens by default in Parity Trick mode.

To access a different mode, the parameter `mode` must be passed with the value list above (for example: Accessing the sandbox mode is done by adding `?mode=sandbox` to the end of the URL).

The following URL parameters can be added to configure how the interactive is loaded:

- `grid-size=X` can preset the grid size where `X` is an integer between 2 and 20.
- `hide-size-controls` will hide the grid size option.
- `show-grid-references` will show the grid references on load.
- `initial-bits=VALUES` can preset the initial bits (not including parity bits), where `VALUES` is a string of `W`s and `B`s to signify white and black squares respectively, left to right, top to bottom.
For example, if you had a grid that is 4 by 4 bits, and you wanted to preset the rows of alternating white and black, `VALUES` would be `WWWBBBWWW` (as parity bits are skipped).

## Required files

The interactive loads from a base website template which includes a JavaScript file containing jQuery, Bootstrap, and a few other utilities and polyfills.
See `static/js/website.js` for a full list.

## Possible future plans

- Add clear button to turn all cards white.
- Add random data button that fills in cards with random values (not parity row).
- Add highlight showing parity error, however this stops opportunities for learning.
60 changes: 47 additions & 13 deletions csfieldguide/static/interactives/parity/js/parity.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var urlParameters = require('../../../js/third-party/url-parameters.js');
var Parity = {};

$(document).ready(function(){
Expand All @@ -7,22 +6,41 @@ $(document).ready(function(){
Parity.feedback = $('#interactive-parity-feedback');
Parity.x_labels = document.getElementById('interactive-parity-grid-x-labels');
Parity.y_labels = document.getElementById('interactive-parity-grid-y-labels');
setupGrid();
setupGridLabels();

if (urlParameters.getUrlParameter('mode') == 'sandbox') {
let searchParameters = new URL(window.location.href).searchParams;

if (searchParameters.has('grid-size')) {
let selectElement = document.getElementById('interactive-parity-grid-size');
let value = searchParameters.get('grid-size');
if (!isNaN(value)) {
selectElement.value = value;
}
}
if (searchParameters.has('show-grid-references')) {
document.getElementById('grid-references-checkbox').checked = true;
showGridReferences(true);
}
if (searchParameters.has('initial-bits')) {
Parity.initial_bits = searchParameters.get('initial-bits');
}
Parity.hide_size_controls = searchParameters.has('hide-size-controls');

if (searchParameters.get('mode') == 'sandbox') {
Parity.mode = 'sandbox';
Parity.current_mode = 'sandbox';
} else if (urlParameters.getUrlParameter('mode') == 'set') {
} else if (searchParameters.get('mode') == 'set') {
Parity.mode = 'set';
Parity.current_mode = 'set';
} else if (urlParameters.getUrlParameter('mode') == 'detect') {
} else if (searchParameters.get('mode') == 'detect') {
Parity.mode = 'detect';
Parity.current_mode = 'detect';
} else {
Parity.mode = 'trick';
Parity.current_mode = 'set';
}

setupGrid();
setupGridLabels();
setupMode();

// On 'Check parity' button click
Expand Down Expand Up @@ -148,15 +166,19 @@ function setupMode() {
if (Parity.current_mode == 'sandbox') {
header.text("Sandbox Mode");
$('.interactive-parity-sandbox-controls').show();
$('.interactive-parity-size-controls').show();
if (!Parity.hide_size_controls) {
$('.interactive-parity-size-controls').show();
}
$('.interactive-parity-check-controls').show();
Parity.flipping = 'all';
setRandomBits();
updateGrid();
} else if (Parity.current_mode == 'set') {
header.text(gettext("Setting Parity"));
Parity.flipping = 'parity';
$('.interactive-parity-size-controls').show();
if (!Parity.hide_size_controls) {
$('.interactive-parity-size-controls').show();
}
if (Parity.mode == 'trick') {
$('.interactive-parity-trick-controls').show();
} else {
Expand All @@ -172,7 +194,9 @@ function setupMode() {
$('.interactive-parity-reset-controls').show();
// If detect only mode (not trick mode)
if (Parity.mode == 'detect') {
$('.interactive-parity-size-controls').show();
if (!Parity.hide_size_controls) {
$('.interactive-parity-size-controls').show();
}
setRandomBits();
setParityBits();
flipBit();
Expand Down Expand Up @@ -211,10 +235,20 @@ function flipBit() {
function setRandomBits() {
for (var row = 0; row < Parity.grid_values.length - 1; row++) {
for (var col = 0; col < Parity.grid_values.length - 1; col++) {
if (Math.random() >= 0.5) {
Parity.grid_values[row][col] = true;
if (Parity.initial_bits) {
let char_position = row * (Parity.grid_values.length - 1) + col;
let initial_bit = Parity.initial_bits.charAt(char_position);
if (initial_bit == 'W') {
Parity.grid_values[row][col] = true;
} else {
Parity.grid_values[row][col] = false;
}
} else {
Parity.grid_values[row][col] = false;
if (Math.random() >= 0.5) {
Parity.grid_values[row][col] = true;
} else {
Parity.grid_values[row][col] = false;
}
}
}
}
Expand Down Expand Up @@ -281,7 +315,7 @@ function setupGrid(){
// Error message
alert(gettext("Please enter a value between 1 and 20"));
// Reset grid
$('##interactive-parity-grid-size').val(6);
$('#interactive-parity-grid-size').val(6);
} else {
Parity.grid.empty();
Parity.x_labels.innerHTML = '';
Expand Down
11 changes: 11 additions & 0 deletions csfieldguide/static/interactives/qr-code-generator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# QR Code Generator Interactive

**Author:** Jack Morgan

This interactive is created for generating and modifying QR Codes.

URL parameters can be added to configure how the interactive is loaded:

- `text=X` can preset the text of the QR code where `X` is a string.
- `level=X` can preset the level of error correction the QR code uses, where `X` is one of the following: `L`, `M`, `Q`, or `H`.
- `hide-controls` can be used to hide the options for the user to change the text and error correction.
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@
color: grey;
margin: 1rem 0;
}
&.hide-controls {
.interactive-controls {
display: none;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ function setup() {

function processURLParameters() {
let searchParameters = new URL(window.location.href).searchParams;
if (searchParameters.has('hide-controls')) {
let element = document.getElementById('qr-code-interactive');
element.classList.add('hide-controls');
}
if (searchParameters.has('text')) {
elementTextContentInput.value = searchParameters.get('text');
}
Expand Down
6 changes: 4 additions & 2 deletions csfieldguide/templates/interactives/qr-code-generator.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1 class="text-center">QR Code Generator</h1>

<div class="row justify-content-center">
<div class="col-12 col-md-10 col-lg-8">
<form>
<form class='interactive-controls'>
<div class="form-row">
<div class="form-group col-12 col-sm-6">
<label for="qr-code-text-content">Text content</label>
Expand All @@ -35,7 +35,9 @@ <h1 class="text-center">QR Code Generator</h1>
</form>

<p>
The QR Code below automatically updates to reflect the settings above.
<span class='interactive-controls'>
The QR Code below automatically updates to reflect the settings above.
</span>
Click on a square in the QR Code to invert it and use a QR Code scanning application on your mobile device to see if it's still readable.
</p>
</div>
Expand Down
19 changes: 19 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ All notable changes to this project will be documented in this file.
We have listed major changes for each release below.
`All downloads are available on GitHub <https://github.com/uccser/cs-field-guide/releases/>`__

3.12.1
==============================================================================

**Release date:** 19th October 2022

**Changelog:**

- Allow QR Code Generator interactive controls to be hidden via URL parameter.
- Allow Parity interactive settings be changed via URL parameter, including setting grid size, presetting intial bit values, hiding controls, and showing grid references.

- Core dependency changes:

- Update crowdin/github-action from 1.4.14 to 1.4.15.
- Update django-modeltranslation from 0.18.4 to 0.18.5.
- Update docker/build-push-action from 3.1.1 to 3.2.0.
- Update docker/login-action from 2.0.0 to 2.1.0.
- Update postcss from 8.4.17 to 8.4.18.
- Update sphinx from 5.2.3 to 5.3.0.

3.12.0
==============================================================================

Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sphinx==5.2.3
sphinx==5.3.0
sphinx-rtd-theme==1.0.0
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cssselect==1.1.0
PyYAML==5.4.1

# I18n
django-modeltranslation==0.18.4
django-modeltranslation==0.18.5
uniseg==0.7.2
python-bidi==0.4.2
django-bidi-utils==1.0
Expand Down

0 comments on commit d963c84

Please sign in to comment.