Skip to content

Commit

Permalink
Extend functionality on already existent blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
simosathan9 committed Aug 7, 2024
1 parent a5c28e6 commit 8d4ed8c
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 18 deletions.
11 changes: 8 additions & 3 deletions public/blocks/catBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ var catBlock = {
category: 'File and Directory Operations',
unix_description: [
{
lineNumbers: '-n'
lineNumbers: '-n',
nonBlank_lineNumbers: '-b'
}
],
message0: '%{BKY_CAT}\n',
message1: '%{BKY_CAT_LINE_NUMBERS} %1',
args1: [
{
type: 'field_checkbox',
type: 'field_dropdown',
name: 'lineNumbers',
checked: false
options: [
['No Line Numbers', 'none'],
['Number All Lines', 'lineNumbers'],
['Number Non-Blank Lines Only', 'nonBlank_lineNumbers']
]
}
],
style: 'File and Directory Operations',
Expand Down
4 changes: 2 additions & 2 deletions public/blocks/cutBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ var cutBlock = {
category: 'Text Processing',
unix_description: [
{
delimiter: "-d'str'",
columns: "-f'str'",
delimiter: "-d 'str'",
columns: '-f str',
charsStart: '-c str',
charsEnd: '-c-str'
}
Expand Down
49 changes: 42 additions & 7 deletions public/blocks/gzipBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@ var gzipBlock = {
unix_description: [
{
keep: '-k',
decompress: '-d'
decompress: '-d',
fast: '-1',
best: '-9',
default: '-6',
two: '-2',
three: '-3',
four: '-4',
five: '-5',
seven: '-7',
eight: '-8',
suffix: '-S str',
verbose: '-v'
}
],
message0: '%{BKY_GZIP_FILE}',
Expand All @@ -13,8 +24,8 @@ var gzipBlock = {
type: 'field_dropdown',
name: 'gzip',
options: [
['compress', 'compress'],
['decompress', 'decompress']
['Compress', 'compress'],
['Decompress', 'decompress']
]
}
],
Expand All @@ -29,11 +40,35 @@ var gzipBlock = {
message2: '%{BKY_GZIP_LEVEL_OF_COMPRESSION}',
args2: [
{
type: 'field_number',
type: 'field_dropdown',
name: 'compress_level',
value: 6, // default number compression level
min: 1,
max: 9
options: [
['-1 (fast)', 'fast'],
['-2', 'two'],
['-3', 'three'],
['-4', 'four'],
['-5', 'five'],
['-6 (default)', 'default'],
['-7', 'seven'],
['-8', 'eight'],
['-9 (best)', 'best']
]
}
],
message3: '%{BKY_GZIP_CHANGE_SUFFIX} %1',
args3: [
{
type: 'field_input',
name: 'suffix',
text: '' // empty text for user to define path
}
],
message4: '%{BKY_GZIP_VERBOSE}',
args4: [
{
type: 'field_checkbox',
name: 'verbose',
checked: false // by default it's disabled
}
],
style: 'File and Directory Operations',
Expand Down
13 changes: 11 additions & 2 deletions public/blocks/rmBlock.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
var rmBlock = {
type: 'rm',
category: 'File and Directory Operations',
message0: 'remove %1',
message1: 'remove %1',
unix_description: [
{
command: 'rm %FILE'
command: 'rm %FILE',
request_confirmation: '-i'
}
],
message0: '%{BKY_RM_REQUEST_CONFIRMATION}',
args0: [
{
type: 'field_checkbox',
name: 'request_confirmation',
checked: false // by default it's disabled
}
],
args1: [
{
type: 'field_input',
name: 'FILE',
Expand Down
20 changes: 19 additions & 1 deletion public/blocks/sortBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ var sortBlock = {
numeric_sorting: '-n',
sort_delimiter: "-t'str'",
sort_column: '-k',
uniq_elements: '-u'
uniq_elements: '-u',
ignore_nonPrintable: '-i',
ignore_leading_blanks: '-b'
}
],
message1: '%{BKY_SORT_DESC}',
Expand Down Expand Up @@ -58,6 +60,22 @@ var sortBlock = {
checked: false // by default it's disabled
}
],
message6: '%{BKY_SORT_IGNORE}',
args6: [
{
type: 'field_checkbox',
name: 'ignore_nonPrintable',
checked: false // by default it's disabled
}
],
message7: '%{BKY_SORT_IGNORE_LEADING_BLANKS}',
args7: [
{
type: 'field_checkbox',
name: 'ignore_leading_blanks',
checked: false // by default it's disabled
}
],

extensions: ['integer_validation'],

Expand Down
11 changes: 10 additions & 1 deletion public/blocks/uniqBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ var uniqBlock = {
unix_description: [
{
none: '',
occurencies: '-c'
occurencies: '-c',
caseInsensitive: '-i'
}
],

Expand All @@ -17,6 +18,14 @@ var uniqBlock = {
checked: false // by default it's disabled
}
],
message2: '%{BKY_UNIQ_CASE}',
args2: [
{
type: 'field_checkbox',
name: 'caseInsensitive',
checked: false // by default it's disabled
}
],

style: 'Text Processing',
previousStatement: 'Action',
Expand Down
6 changes: 6 additions & 0 deletions public/js/el.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ Blockly.Msg['GREP_HELPURL'] = 'https://www.google.com/';
Blockly.Msg['GZIP_FILE'] = '%1 Αρχείο';
Blockly.Msg['GZIP_KEEP_ORIGINAL_FILE'] = 'διατήρηση αρχικού αρχείου %1';
Blockly.Msg['GZIP_LEVEL_OF_COMPRESSION'] = 'επίπεδο συμπίεσης %1';
Blockly.Msg['GZIP_CHANGE_SUFFIX'] = 'Aλλαγή κατάληξης απο .gz σε';
Blockly.Msg['GZIP_VERBOSE'] = 'Εμφάνισε πληροφορίες %1';
Blockly.Msg['GZIP_TOOLTIP'] = 'Συμπίεση/αποσυμπίεση αρχείου';
Blockly.Msg['GZIP_HELPURL'] = 'https://www.google.com/';
Blockly.Msg['HEAD_MESSAGE'] = 'Αρχή αρχείου';
Expand Down Expand Up @@ -583,6 +585,7 @@ Blockly.Msg['REMOVE_COMMENT'] = 'Αφαίρεση σχολίου';
Blockly.Msg['RENAME_VARIABLE'] = 'Μετονομασία μεταβλητής...';
Blockly.Msg['RENAME_VARIABLE_TITLE'] =
"Μετονομασία όλων των μεταβλητών '%1' σε:";
Blockly.Msg['RM_REQUEST_CONFIRMATION'] = 'Αίτημα επιβεβαίωσης για αφαίρεση %1';
Blockly.Msg['TEXT_APPEND_HELPURL'] =
'https://github.com/google/blockly/wiki/Text#text-modification';
Blockly.Msg['TEXT_APPEND_TITLE'] = 'στο %1 προσθήκη κειμένου %2';
Expand Down Expand Up @@ -820,6 +823,8 @@ Blockly.Msg['SORT_BASED'] = 'με βάση %1';
Blockly.Msg['SORT_DELIM'] = 'διαχωριστικό %1';
Blockly.Msg['SORT_COLS'] = 'στήλη για ταξινόμηση %1';
Blockly.Msg['SORT_UNIQ'] = 'έξοδος μοναδικών στοιχείων %1';
Blockly.Msg['SORT_IGNORE'] = 'αγνόηση μη εκτυπώσιμων χαρακτήρων %1';
Blockly.Msg['SORT_IGNORE_LEADING_BLANKS'] = 'αγνόηση κενών στην αρχή %1';
Blockly.Msg['SORT_TOOLTIP'] =
'αναφορά ή φιλτράρισμα επαναλαμβανόμενων γραμμών σε ένα αρχείο';
Blockly.Msg['SORT_HELPURL'] = 'https://www.google.com/';
Expand All @@ -845,6 +850,7 @@ Blockly.Msg['TOUCH_HELPURL'] = 'https://www.google.com/';
Blockly.Msg['UNIQ'] = 'Αφαίρεση διπλότυπων γραμμών στο αρχείο\n';
Blockly.Msg['UNIQ_COUNT'] =
'μέτρηση των εμφανίσεων των \n γραμμών που αφαιρέθηκαν %1';
Blockly.Msg['UNIQ_CASE'] = ' χωρίς διάκριση πεζών-κεφαλαίων %1';
Blockly.Msg['UNIQ_TOOLTIP'] =
'Αναφορά ή φιλτράρισμα επαναλαμβανόμενων γραμμών σε ένα αρχείο';
Blockly.Msg['UNIQ_HELPURL'] = 'https://www.google.com/';
Expand Down
9 changes: 8 additions & 1 deletion public/js/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ Blockly.Msg['GREP_MULTIPLE_PATTERN_SEARCH'] =
Blockly.Msg['GREP_SHOW_FILENAME'] = 'Show filename %1';
Blockly.Msg['GREP_TOOLTIP'] = 'search in a file with a pattern';
Blockly.Msg['GREP_HELPURL'] = 'https://www.google.com/';
Blockly.Msg['GZIP_FILE'] = '%1 File';
Blockly.Msg['GZIP_FILE'] = '%1 file';
Blockly.Msg['GZIP_KEEP_ORIGINAL_FILE'] = 'keep original file %1';
Blockly.Msg['GZIP_LEVEL_OF_COMPRESSION'] = 'level of compression %1';
Blockly.Msg['GZIP_CHANGE_SUFFIX'] = 'Change suffix from .gz to';
Blockly.Msg['GZIP_VERBOSE'] = 'Τurn on verbose mode %1';
Blockly.Msg['GZIP_TOOLTIP'] = 'File compress/decompress';
Blockly.Msg['GZIP_HELPURL'] = 'https://www.google.com/';
Blockly.Msg['HEAD_MESSAGE'] = 'Head of file';
Expand Down Expand Up @@ -572,6 +574,8 @@ Blockly.Msg['REGOR_CREATE_WITH'] = 'multiple patterns';
Blockly.Msg['REMOVE_COMMENT'] = 'Remove Comment';
Blockly.Msg['RENAME_VARIABLE'] = 'Rename variable...';
Blockly.Msg['RENAME_VARIABLE_TITLE'] = "Rename all '%1' variables to:";
Blockly.Msg['RM_REQUEST_CONFIRMATION'] =
'Request confirmation before deleting %1';
Blockly.Msg['TEXT_APPEND_HELPURL'] =
'https://github.com/google/blockly/wiki/Text#text-modification';
Blockly.Msg['TEXT_APPEND_TITLE'] = 'to %1 append text %2';
Expand Down Expand Up @@ -798,6 +802,8 @@ Blockly.Msg['SORT_BASED'] = 'based on %1';
Blockly.Msg['SORT_DELIM'] = 'delimeter %1';
Blockly.Msg['SORT_COLS'] = 'column to sort %1';
Blockly.Msg['SORT_UNIQ'] = 'unique elements output %1';
Blockly.Msg['SORT_IGNORE'] = 'ignore non-printable characters %1';
Blockly.Msg['SORT_IGNORE_LEADING_BLANKS'] = 'ignore leading blanks %1';
Blockly.Msg['SORT_TOOLTIP'] = 'report or filter out repeated lines in a file';
Blockly.Msg['SORT_HELPURL'] = 'https://www.google.com/';

Expand All @@ -822,6 +828,7 @@ Blockly.Msg['TOUCH_HELPURL'] = 'https://www.google.com/';
Blockly.Msg['UNIQ'] = 'Remove duplicate lines in file\n';
Blockly.Msg['UNIQ_COUNT'] =
'count the occurencies of \n duplicates lines removed %1';
Blockly.Msg['UNIQ_CASE'] = 'case sensitive %1';
Blockly.Msg['UNIQ_TOOLTIP'] = 'Report or filter out repeated lines in a file';
Blockly.Msg['UNIQ_HELPURL'] = 'https://www.google.com/';

Expand Down
2 changes: 1 addition & 1 deletion public/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ replacementMap.set(/\/\s{1,}/g, '/');
replacementMap.set(/\/\'\s{1,}g/g, "/g'");

//used for gzip
replacementMap.set(/\s.?-k\s{1,}/g, '-k');
replacementMap.set(/\s.?-k\s{1,}/g, '-k ');

//used for exec parameter in find
replacementMap.set(/{}.\\;.*?\|.*/g, '{} \\;');
Expand Down
14 changes: 14 additions & 0 deletions views/tutorials.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,20 @@
</p>
</div>
</li>
<li>
<div data-bs-toggle="collapse" href="#faq7" class="collapsed question">Extracting Specific Columns from a File and Saving to a New File<i class="bi bi-chevron-down icon-show"></i><i class="bi bi-chevron-up icon-close"></i></div>
<div id="faq7" class="collapse" data-bs-parent=".faq-list">
<p>
Extract columns 1 and 3 from a CSV file and save the output to a new file.
</p>
<div class="image-container">
<img src="img/extract_columns.png" alt="Blockly Unix" class="img-fluid" style="width: 700px; height: auto;">
</div>
<p>
The corresponding Unix command for this task is: <strong>sed 's/oldtext/newtext/g' file.txt | sort | uniq -c | sort -r -n</strong>
</p>
</div>
</li>
</ul>

</div>
Expand Down

0 comments on commit 8d4ed8c

Please sign in to comment.