Skip to content

Commit 369bee0

Browse files
authored
Merge pull request #5144 from Catrobat/jquery5
Remove jquery again
2 parents c2f262f + 6261c71 commit 369bee0

File tree

8 files changed

+105
-202
lines changed

8 files changed

+105
-202
lines changed

.github/workflows/create_release_pull_request.yaml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2+
# ** Release preparation **
3+
#
4+
# This workflow create 2 pull requests branching from develop into:
5+
# - master
6+
# - develop
7+
#
8+
# The pull request contains:
9+
# - Bump release version -> .env
10+
#
11+
# Additionally, a tag and gitHub release is created for the new release version
12+
# After merging the newly created PRs, start the deployment
13+
#
114
name: Create Release PR
215

316
on:
@@ -19,28 +32,28 @@ jobs:
1932
# Extract the current version from the .env file
2033
current_version=$(grep -oP "(?<=APP_VERSION=')[0-9]{2}\.[0-9]{1,2}\.[0-9]{1,5}" .env)
2134
IFS=' ' read -r major minor patch <<< "$(echo $current_version | awk -F'.' '{print $1, $2, $3}')"
22-
35+
2336
# Now you can use $year, $month, and $day
2437
#echo "current version: $current_version"
2538
#echo "major (year): $major"
2639
#echo "minor (month): $minor"
2740
#echo "patch: $patch"
28-
41+
2942
# Increment the patch version
3043
new_patch=$((patch + 1))
31-
44+
3245
# Get current year and month
3346
current_year=$(date +%y)
3447
current_month=$(date +%-m)
35-
48+
3649
# If the current year or month is different, reset the patch version
3750
if [[ $major -ne $current_year || $minor -ne $current_month ]]; then
3851
new_patch=0
3952
fi
40-
53+
4154
# Formulate the new version
4255
new_version="${current_year}.${current_month}.${new_patch}"
43-
56+
4457
# Output the new version
4558
#echo "new version: $new_version"
4659
echo $new_version

assets/catblocks/main.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ img {
207207
--white: #fff;
208208
--gray: #6c757d;
209209
--gray-dark: #343a40;
210-
--primary: #007bff;
211210
--secondary: #6c757d;
212211
--success: #28a745;
213212
--info: #17a2b8;

assets/js/code_view.js

Lines changed: 60 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,68 @@
1-
// import { CatBlocks } from '../catblocks/CatBlocks' // CatBlocks needs export!
1+
/* global CatBlocks */
22

33
require('../styles/components/code_view.scss')
44

55
document.addEventListener('DOMContentLoaded', () => {
6-
// const codeViewElement = document.querySelector('.js-code-view');
7-
// const appEnv = codeViewElement.getAttribute('data-app-env');
8-
// const locale = codeViewElement.getAttribute('data-locale');
9-
// const extractedProjectPath = codeViewElement.getAttribute('data-extracted-project-path');
10-
// const projectHash = codeViewElement.getAttribute('data-project-hash');
11-
//
12-
// if (appEnv === 'test') {
13-
// disableCodeViewInTestEnv();
14-
// } else {
15-
// initializeCodeView();
16-
// }
17-
//
18-
// function initializeCodeView() {
19-
// /*
20-
// * initiate CatBlocks
21-
// *
22-
// * define element:
23-
// * - container to inject CatBlocks hidden workflow
24-
// * - renderSize to use for blocks
25-
// * - shareRoot
26-
// * - language to use for rendering texts
27-
// * - i18n to define the path to the translations
28-
// * - media for CatBlocks
29-
// * - noImageFound is unused, just a placeholder for now
30-
// */
31-
// CatBlocks.init({
32-
// container: 'catblocks-code-container',
33-
// renderSize: 0.75,
34-
// language: locale,
35-
// shareRoot: 'catblocks',
36-
// media: 'media',
37-
// i18n: 'i18n',
38-
// noImageFound: 'No_Image_Available.jpg'
39-
// });
40-
//
41-
// /**
42-
// * start rendering program into div
43-
// */
44-
// window.onload = function () {
45-
// CatBlocks.render(extractedProjectPath, projectHash)
46-
// .catch(err => {
47-
// console.error('Failed to parse catroid file.');
48-
// console.error(err);
49-
// console.warn('Using old code view instead of new one');
50-
// // Show old view instead
51-
// document.getElementById('catblocks-code-container').innerHTML = '';
52-
// document.getElementById('codeview-wrapper').classList.remove('d-none');
53-
// document.getElementById('code-view-spinner').classList.add('d-none');
54-
// })
55-
// .finally(() => {
56-
// document.getElementById('code-view-spinner').classList.add('d-none');
57-
// document.getElementById('code-view-toggler').classList.remove('d-none');
58-
// // CatBlocks need a visible container to calculate the svg sizes.
59-
// // Still it should be collapsed on a page load.
60-
// const collapseCodeView = document.getElementById('collapseCodeView');
61-
// collapseCodeView.classList.add('collapse', 'hide');
62-
// });
63-
// };
64-
// }
65-
//
66-
// function disableCodeViewInTestEnv() {
67-
// console.log('Catblocks must be disabled in the test env. Why?\n' +
68-
// 'Catblocks uses blockly which results in a crash our test system (Behat tests + chrome headless)\n' +
69-
// 'Where? @ init -> blockly.inject(...)\n' +
70-
// '\n' +
71-
// 'What do we know so far?\n' +
72-
// 'Pretty sure the fault is not by Catblocks. Even the simple blockly demo crashs -> \n' +
73-
// ' Given I am on "https://blockly-demo.appspot.com/static/demos/fixed/index.html"\n' +
74-
// ' And I should see "Fixed Blockly"\n' +
75-
// ' Then the element "#blocklyDiv" should be visible\n' +
76-
// '\n' +
77-
// 'Chrome crash does not give much useful information, only that much memory was allocated\n' +
78-
// 'The bug could be either in the chrome headless or the mink implementation\n' +
79-
// 'Large sites per se seem not to be the problem. E.g. tested with https://scratch.mit.edu/projects/390060499/\n' +
80-
// '\n'
81-
// );
82-
// document.getElementById('catblocks-code-container').textContent =
83-
// 'Disabled in test env due to problems in the chrome headless/mink/blockly interactions';
84-
// }
6+
const codeView = document.querySelector('.js-code-view')
7+
const locale = codeView.dataset.locale
8+
const extractedProjectPath = codeView.dataset.extractedProjectPath
9+
const projectHash = codeView.dataset.projectHash
8510

11+
initializeCodeView()
12+
13+
function initializeCodeView() {
14+
/*
15+
* initiate CatBlocks
16+
*
17+
* define element:
18+
* - container to inject CatBlocks hidden workflow
19+
* - renderSize to use for blocks
20+
* - shareRoot
21+
* - language to use for rendering texts
22+
* - i18n to define the path to the translations
23+
* - media for CatBlocks
24+
* - noImageFound is unused, just a placeholder for now
25+
*/
26+
CatBlocks.init({
27+
container: 'catblocks-code-container',
28+
renderSize: 0.75,
29+
language: locale,
30+
shareRoot: 'catblocks',
31+
media: 'media',
32+
i18n: 'i18n',
33+
noImageFound: 'No_Image_Available.jpg',
34+
})
35+
36+
/**
37+
* start rendering project into div
38+
*/
39+
window.onload = function () {
40+
CatBlocks.render(extractedProjectPath, projectHash)
41+
.catch((err) => {
42+
console.error('Failed to parse catroid file.')
43+
console.error(err)
44+
console.error('Using old code view instead of new one')
45+
// Show old view instead
46+
document.getElementById('catblocks-code-container').innerHTML = ''
47+
document.getElementById('codeview-wrapper').classList.remove('d-none')
48+
document.getElementById('code-view-spinner')?.classList.add('d-none')
49+
})
50+
.finally(() => {
51+
document.getElementById('code-view-spinner').classList.add('d-none')
52+
document
53+
.getElementById('code-view-toggler')
54+
.classList.remove('d-none')
55+
// CatBlocks need a visible container to calculate the svg sizes.
56+
// Still it should be collapsed on a page load.
57+
const collapseCodeView = document.getElementById('collapseCodeView')
58+
collapseCodeView?.classList.add('collapse')
59+
collapseCodeView?.classList.add('hide')
60+
})
61+
}
62+
}
63+
})
64+
65+
document.addEventListener('DOMContentLoaded', () => {
8666
// Old Code View!!
8767
document.querySelectorAll('.collapse-btn').forEach((btn) => {
8868
btn.addEventListener('click', function () {

assets/js/components/text_fill_default.js

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
1-
import $ from 'jquery'
21
import TextFill from 'textfilljs'
32

43
export default function (container) {
5-
const maxFontPixels = parseFloat($(container).css('font-size'))
4+
const containerElem =
5+
typeof container === 'string'
6+
? document.querySelector(container)
7+
: container
8+
9+
if (!containerElem) {
10+
console.error('Container element not found.')
11+
return
12+
}
13+
14+
const style = window.getComputedStyle(containerElem)
15+
const maxFontPixels = parseFloat(style.fontSize)
616
const minFontPixels = Math.round(maxFontPixels * 0.7)
717

8-
const html = $(container).html()
9-
$(container).empty()
10-
const $span = $('<span/>').html(html)
11-
$(container).append($span)
18+
const html = containerElem.innerHTML
19+
containerElem.innerHTML = ''
20+
const span = document.createElement('span')
21+
span.innerHTML = html
22+
containerElem.appendChild(span)
1223

13-
TextFill(container, {
24+
TextFill(containerElem, {
1425
maxFontPixels,
1526
minFontPixels,
1627
widthOnly: true,
1728
innerTag: 'span',
1829
fail: function () {
19-
$(container).addClass('force-word-break')
20-
$(container).html(html)
30+
containerElem.classList.add('force-word-break')
31+
containerElem.innerHTML = html
2132
},
2233
success: function () {
23-
$(container).removeClass('force-word-break')
24-
const newFontSize = $span.css('font-size')
25-
$(container).html(html)
34+
containerElem.classList.remove('force-word-break')
35+
const newFontSize = window.getComputedStyle(span).fontSize
36+
containerElem.innerHTML = html
2637
if (parseFloat(newFontSize) < maxFontPixels) {
27-
$(container).css('font-size', newFontSize)
38+
containerElem.style.fontSize = newFontSize
2839
}
2940
},
3041
})
Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
{% extends 'Default/base.html.twig' %}
22
{% block page_title %}{{ "codeview.title"|trans({}, "catroweb") }}{% endblock %}
33
{% block back_path %}{{ path('program', { 'id' : id }) }}{% endblock %}
4-
{# Catblocks is broken in the moment therefor no search would work. ToDo: Enable as soon as it's working again #}
5-
{% block no_search %}true{% endblock %}
6-
74

85
{% block head %}
9-
{# Until catblocks supports bs5 #}
10-
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
116
{{ encore_entry_link_tags('code_view') }}
7+
<script src="{{ asset('catblocks/CatBlocks.js') }}"></script>
128
{% endblock %}
139

1410
{% block body %}
15-
1611
<div class="d-flex justify-content-center">
1712
<i class="material-icons" id="code-view-spinner">
1813
{% include 'components/loading_spinner.html.twig' with {'spinner_id': 'code-view-spinner' ~ suffix|default()} %}
@@ -38,96 +33,6 @@
3833

3934

4035
{% block javascript %}
41-
4236
{{ encore_entry_script_tags('code_view') }}
43-
44-
{# Until catblocks supports bs5 #}
45-
<script src="{{ asset('js/modules/jquery.min.js') }}"></script>
46-
<script src="{{ asset('catblocks/CatBlocks.js') }}"></script>
47-
48-
<script>
49-
$(() => {
50-
const $codeView = $('.js-code-view')
51-
const appEnv = $codeView.data('app-env')
52-
const locale = $codeView.data('locale')
53-
const extractedProjectPath = $codeView.data('extracted-project-path')
54-
const projectHash = $codeView.data('project-hash')
55-
56-
if (appEnv === 'test') {
57-
disableCodeViewInTestEnv()
58-
} else {
59-
initializeCodeView()
60-
}
61-
62-
function initializeCodeView () {
63-
/*
64-
* initiate CatBlocks
65-
*
66-
* define element:
67-
* - container to inject CatBlocks hidden workflow
68-
* - renderSize to use for blocks
69-
* - shareRoot
70-
* - language to use for rendering texts
71-
* - i18n to define the path to the translations
72-
* - media for CatBlocks
73-
* - noImageFound is unused, just a placeholder for now
74-
*/
75-
CatBlocks.init({
76-
container: 'catblocks-code-container',
77-
renderSize: 0.75,
78-
language: locale,
79-
shareRoot: 'catblocks',
80-
media: 'media',
81-
i18n: 'i18n',
82-
noImageFound: 'No_Image_Available.jpg'
83-
})
84-
85-
/**
86-
* start rendering project into div
87-
*/
88-
window.onload = function () {
89-
CatBlocks.render(extractedProjectPath, projectHash)
90-
.catch(err => {
91-
console.error('Failed to parse catroid file.')
92-
console.error(err)
93-
console.error('Using old code view instead of new one')
94-
// Show old view instead
95-
$('#catblocks-code-container').innerHTML = ''
96-
$('#codeview-wrapper').removeClass('d-none')
97-
$('#code-view-spinner').addClass('d-none')
98-
})
99-
.finally(() => {
100-
$('#code-view-spinner').addClass('d-none')
101-
$('#code-view-toggler').removeClass('d-none')
102-
// CatBlocks need a visible container to calculate the svg sizes.
103-
// Still it should be collapsed on a page load.
104-
$('#collapseCodeView').addClass('collapse').addClass('hide')
105-
})
106-
}
107-
}
108-
109-
function disableCodeViewInTestEnv () {
110-
console.log('Catblocks must be disabled in the test env. Why?\n' +
111-
'Catblocks uses blockly which results in a crash our test system (Behat tests + chrome headless)\n' +
112-
'Where? @ init -> blockly.inject(...)\n' +
113-
'\n' +
114-
'What do we know so far?\n' +
115-
'Pretty sure the fault is not by Catblocks. Even the simple blockly demo crashs -> \n' +
116-
' Given I am on "https://blockly-demo.appspot.com/static/demos/fixed/index.html"\n' +
117-
' And I should see "Fixed Blockly"\n' +
118-
' Then the element "#blocklyDiv" should be visible\n' +
119-
'\n' +
120-
'Chrome crash does not give much useful information, only that much memory was allocated\n' +
121-
'The bug could be either in the chrome headless or the mink implementation\n' +
122-
'Large sites per se seem not to be the problem. E.g. tested with https://scratch.mit.edu/projects/390060499/\n' +
123-
'\n'
124-
)
125-
$('#catblocks-code-container').text(
126-
'Disabled in test env due to problems in the chrome headless/mink/blockly interactions'
127-
)
128-
}
129-
})
130-
</script>
131-
13237
{% endblock %}
13338

tests/BehatFeatures/web/code-view/project_code_view.feature

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ Feature: As a visitor I want to see the code view on a project page
3838
And I am on "/app/project/1/code_view"
3939
And the element "#codeview-wrapper" should be visible
4040

41-
@disabled
4241
Scenario: The code view should use an accordion principle. It must be displayed instead of the old code view
43-
# Disabled due to problems in the chrome headless/mink/blockly interactions
4442
Given I have a project zip "CodeStatistics/new_code_view.catrobat"
4543
And I upload this generated project with id "1", API version 1
4644
And I am on "/app/project/1/code_view"
4745
And I wait for the page to be loaded
48-
Then I should see "NewCodeView"
46+
Then I should see "New Code View"
4947
And the element "#codeview-wrapper" should not be visible
5048
And the element ".catblocks-scene-header" should be visible
-212 KB
Binary file not shown.

0 commit comments

Comments
 (0)