Skip to content

Commit

Permalink
Merge pull request #1074 from openwebwork/PG-2.19
Browse files Browse the repository at this point in the history
PG 2.19 Release Candidate
  • Loading branch information
drgrice1 authored Aug 6, 2024
2 parents 2bd3ca3 + f7c8b67 commit 88420fc
Show file tree
Hide file tree
Showing 267 changed files with 18,522 additions and 11,325 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
max_line_length = 120
trim_trailing_whitespace = true
indent_style = tab
indent_size = 4

[*.yml]
indent_style = space
indent_size = 2

[*.pg]
trim_trailing_whitespace = false
44 changes: 44 additions & 0 deletions .github/workflows/check-formats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Check Formatting of Code Base

defaults:
run:
shell: bash

on:
push:
branches-ignore: [main, develop]
pull_request:

jobs:
perltidy:
name: Check Perl file formatting with perltidy
runs-on: ubuntu-22.04
container:
image: perl:5.34
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: cpanm -n Perl::Tidy@20220613
- name: Run perltidy
shell: bash
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
shopt -s extglob globstar nullglob
perltidy --pro=./.perltidyrc -b -bext='/' ./**/*.p[lm] ./**/*.t && git diff --exit-code
prettier:
name: Check JavaScript, style, and HTML file formatting with prettier
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Dependencies
run: cd htdocs && npm ci --ignore-scripts
- name: Check formatting with prettier
run: cd htdocs && npm run prettier-check
32 changes: 0 additions & 32 deletions .github/workflows/linter.yml

This file was deleted.

4 changes: 3 additions & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout PG code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Ubuntu dependencies
run: |
Expand All @@ -28,6 +28,8 @@ jobs:
libhtml-parser-perl \
libjson-perl \
libjson-xs-perl \
liblocale-maketext-lexicon-perl \
libmojolicious-perl \
libtest2-suite-perl \
libtie-ixhash-perl \
libuuid-tiny-perl \
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
conf/pg_config.yml
*~
*.swp
*.bak

conf/pg_config.yml
cover_db/

htdocs/node_modules
Expand Down
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"printWidth": 120,
"semi": true,
"singleQuote": true,
"trailingComma": "none"
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Online Homework Delivery System
Version 2.*

Copyright 2000-2023, The WeBWorK Project
Copyright 2000-2024, The WeBWorK Project
All rights reserved.

This program is free software; you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

http://webwork.maa.org/wiki/Category:Release_Notes

Copyright 2000-2023, The WeBWorK Project
Copyright 2000-2024, The WeBWorK Project
http://webwork.maa.org
All rights reserved.
4 changes: 2 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$PG_VERSION ='2.18';
$PG_COPYRIGHT_YEARS = '1996-2023';
$PG_VERSION ='2.19';
$PG_COPYRIGHT_YEARS = '1996-2024';

1;
4 changes: 4 additions & 0 deletions assets/tex/pg.sty
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@
% semantic macro definitions used by PG
\newcommand{\answerRule}[2][]{\raisebox{-3pt}{\parbox[t]{#2ex}{\hrulefill}}}

% height of a strut, used for example to possition the top border of an inline image
% unit is initialized here, but value is set locally where needed
\newlength{\strutheight}

99 changes: 99 additions & 0 deletions bin/convert-to-pgml.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/usr/bin/env perl
################################################################################
# WeBWorK Online Homework Delivery System
# Copyright © 2000-2024 The WeBWorK Project, https://github.com/openwebwork
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of either: (a) the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any later
# version, or (b) the "Artistic License" which comes with this package.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the
# Artistic License for more details.
################################################################################

=head1 NAME
convert-to-pgml.pl -- Convert pg problem with non-pgml structure to PGML structure.
=head1 SYNOPSIS
convert-to-pgml -b -s pgml file1.pg file2.pg ...
=head1 DESCRIPTION
This converts each pg file to PGML formatting. In particular, text blocks are
converted to their PGML forms. This includes BEGIN_TEXT/END_TEXT, BEGIN_HINT/END_HINT,
BEGIN_SOLUTION/END_SOLUTION.
Within each block, the following are converted: math modes to their PGML version,
$BR and $PAR to line breaks or empty lines, C<$HR> to C<--->, bold and italics pairs,
any variables of the form C<$var> to C<[$var]>, scripts from \{ \} to [@ @], and C<ans_rule>
to the form C<[_]{}>
Many code features that are no longer needed are removed including
C<TEXT(beginproblem())>, C<<Context()->texStrings;>> and C<<Context()->normalStrings;>>.
Any C<ANS> commands are commented out.
The C<loadMacros> command is parsed, the C<PGML.pl> is included and C<MathObjects.pl>
is removed (because it is loaded by C<PGML.pl>) and C<PGcourse.pl> is added to the
end of the list.
Note: many of the features are converted correctly, but often there will be errors
after the conversion. Generally after using this script, the PGML style answers
will need to have their corresponding variable added.
=head2 OPTIONS
The option C<-b> or C<--backup> will create a C<.bak> file with the original code and
replace the current file with the converted code.
The option C<-s xyz> or C<--suffix=xyz> will convert the code and write the results in a file
with the given suffix C<xyz> appended to the file name. If this is not given
C<pgml> is used. If the C<-b> flag is used, this option will be ignored.
=cut

use strict;
use warnings;
use experimental 'signatures';

use Mojo::File qw(curfile);
use Getopt::Long;

use lib curfile->dirname->dirname . '/lib';

use WeBWorK::PG::ConvertToPGML qw(convertToPGML);

my $backup = 0;
my $verbose = 0;
my $suffix = 'pgml';

GetOptions(
"b|backup" => \$backup,
"s|suffix=s" => \$suffix,
"v|verbose" => \$verbose,
);

die 'arguments must have a list of pg files' unless @ARGV > 0;
convertFile($_) for (grep { $_ =~ /\.pg$/ } @ARGV);

sub convertFile ($filename) {
my $path = Mojo::File->new($filename);
die "The file: $filename does not exist or is not readable" unless -r $path;

my $pg_source = $path->slurp;
my $converted_source = convertToPGML($pg_source);

# copy the original file to a backup and then write the file
my $new_path = $backup ? $path : Mojo::File->new($filename =~ s/\.pg/.$suffix/r);
my $backup_file = $filename =~ s/\.pg$/.pg.bak/r;
$path->copy_to($backup_file) if $backup;
$new_path->spurt($converted_source);
print "Writing converted file to $new_path\n" if $verbose;
print "Backing up original file to $backup_file\n" if $verbose && $backup;
}

1;
2 changes: 1 addition & 1 deletion bin/perltidy-pg.pl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
################################################################################
# WeBWorK Online Homework Delivery System
# Copyright &copy; 2000-2023 The WeBWorK Project, https://github.com/openwebwork
# Copyright &copy; 2000-2024 The WeBWorK Project, https://github.com/openwebwork
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of either: (a) the GNU General Public License as published by the
Expand Down
2 changes: 1 addition & 1 deletion bin/run-perltidy.pl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
################################################################################
# WeBWorK Online Homework Delivery System
# Copyright &copy; 2000-2023 The WeBWorK Project, https://github.com/openwebwork
# Copyright &copy; 2000-2024 The WeBWorK Project, https://github.com/openwebwork
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of either: (a) the GNU General Public License as published by the
Expand Down
65 changes: 65 additions & 0 deletions bin/update-localization-files
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash

function print_help_exit
{
printf "Usage: %s [options]\n" $(basename $0) >&2
printf " Update the pg.pot and language .po files with translation strings from the code.\n" >&2
printf " options:\n" >&2
printf " -p|--po-update Update po files as well. By default only the pg.pot file is updated.\n" >&2
printf " -l|--langauge Update the only given language in addition to updating the pg.pot file.\n" >&2
printf " -h|--help Show this help.\n" >&2
exit 1
}

TEMP=$(getopt -a -o pl:h -l po-update,language:,help -n "$(basename $0)" -- "$@")

eval set -- "$TEMP"

UPDATE_PO=false
LANGUAGE=""

while [ ! "$1" = "--" ]
do
case "$1" in
-p|--po-update)
UPDATE_PO=true
shift 1
;;
-l|--language)
LANGUAGE=$2
shift 2
;;
-h|--help)
print_help_exit
;;
*)
echo "Internal error!"
exit 1
;;
esac
done

if [ -z "$PG_ROOT" ]; then
echo >&2 "You need to set the PG_ROOT environment variable. Aborting."
exit 1
fi

command -v xgettext.pl >/dev/null 2>&1 || {
echo >&2 "xgettext.pl needs to be installed. It is inlcuded in the perl package Locale::Maketext::Extract. Aborting.";
exit 1;
}

LOCDIR=$PG_ROOT/lib/WeBWorK/PG/Localize

cd $LOCDIR

echo "Updating $LOCDIR/pg.pot"

xgettext.pl -o pg.pot -D $PG_ROOT/lib -D $PG_ROOT/macros

if $UPDATE_PO; then
find $LOCDIR -name '*.po' -exec bash -c "echo \"Updating {}\"; msgmerge -qUN {} pg.pot" \;
elif [[ $LANGUAGE != "" && -e "$LANGUAGE.po" ]]; then
echo "Updating $LOCDIR/$LANGUAGE.po"
msgmerge -qUN $LANGUAGE.po pg.pot
fi
Loading

0 comments on commit 88420fc

Please sign in to comment.