diff --git a/.github/workflows/backend-and-models.yml b/.github/workflows/backend-and-models.yml index 3d4b1182..fed68753 100644 --- a/.github/workflows/backend-and-models.yml +++ b/.github/workflows/backend-and-models.yml @@ -16,7 +16,7 @@ jobs: - ubuntu-20.04 - ubuntu-latest raku-version: - - '2023.02' + - '2023.04' runs-on: ${{ matrix.os }} services: diff --git a/Makefile.am b/Makefile.am index 60e117d3..8e61a11a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,16 +2,20 @@ AUTOMAKE_OPTIONS = foreign - -SUBDIRS = thirdparty etc frontend +SUBDIRS = thirdparty etc frontend lib bin PUB := $(shell find -L public -type d \( -name ".??*" -o -name transpiled \) -prune -o -not -name "*db.json" -a -not -name "*.map" -a -not -name "*~" -a -not -name transpiled -a -not -name "*.tmp" -a -type f -print ) TEMPL := $(shell test -d templates && find -L templates -type f -name "*.ep") -SHARE := $(shell test -d share && find -L share -type d -name ".??*" -prune -o -not -name ".*" -a -not -name "*~" -a -not -name "*.tmp" -a -type f -print) +SHARE := $(shell test -d share && find -L share -type d -name ".??*" -prune -o -not -name ".*" -a -not -name "*~" -a -not -wholename "*/Docu/*" -a -not -name "*.tmp" -a -type f -print) PERLTESTS := $(shell find t -name "*.t") PM := $(shell find lib -name "*.pm") -EXTRA_DIST = VERSION cpanfile COPYRIGHT LICENSE CHANGES AUTHORS bootstrap $(PUB) $(wildcard t/*.t) $(POD) $(TEMPL) $(PERLTESTS) $(SHARE) Dockerfile +EXTRA_DIST = VERSION cpanfile COPYRIGHT CHANGELOG.md README.md bootstrap $(PUB) $(wildcard t/*.t) $(POD) $(TEMPL) $(PERLTESTS) $(SHARE) META6.json + +datadir = $(prefix) +nobase_data_DATA = $(PUB) $(TEMPL) $(SHARE) +VERSION: + jq '.version' < META6.json | tr -d '"\n' > VERSION diff --git a/README.md b/README.md index 3cba2453..276500d2 100644 --- a/README.md +++ b/README.md @@ -42,9 +42,9 @@ CREATE DATABASE agrammon OWNER agrammon; Load a database dump (auto creation not yet implemented) -## Installation Web App +## Setup Web App -Install npm and jq from your distro and then run +Install npm, jq, and libperl-dev from your distro and then run mkdir -p public # first time only ./bootstrap @@ -62,3 +62,18 @@ and point your browser to the shown URL (defaults to localhost:20000) The Agrammon model can be accessed via a REST interface, for details see the [online documentation](https://redocly.github.io/redoc/?url=https://model.agrammon.ch/single/api/v1/openapi.yaml) + +## Server Installation + +./bootstrap +./make dist +scp agrammon-$VERSION.tar.gz server:sources/ +ssh server +cd sources +tar zxf agrammon-$VERSION.tar.gz +cd agrammon-$VERSION +./configure --prefix=DESTDIR +make +make install + +(Re-) start agrammon service with appropriate config file diff --git a/VERSION b/VERSION index 19b860c1..c0be8a79 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.4.0 +6.4.0 \ No newline at end of file diff --git a/bin/agrammon.raku b/bin/agrammon.raku index 62b146c5..f498eb93 100755 --- a/bin/agrammon.raku +++ b/bin/agrammon.raku @@ -1,3 +1,7 @@ -#!/usr/bin/env perl6 +#!/usr/bin/env raku + +BEGIN my $root = $*PROGRAM.resolve.parent(2); +use lib "$root/lib".Str; +use lib:from "$root/Inline/perl5"; use Agrammon::UI::CommandLine; diff --git a/configure.ac b/configure.ac index b64433df..09b3bc59 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ # Copyright (C) 2020 Oetiker+Partner AG -AC_INIT([agrammon],m4_esyscmd([jq '.version' < META6.json | tr -d '""' ]),[fritz.zaucker@oetiker.ch]) +AC_INIT([agrammon],m4_esyscmd([jq '.version' < META6.json | tr -d '"\n']),[fritz.zaucker@oetiker.ch]) AC_PREREQ([2.59]) AC_CONFIG_AUX_DIR(conftools) @@ -31,6 +31,14 @@ AC_PATH_PROG(NPX, npx, npx-not-found) AC_PATH_PROG(XGETTEXT, xgettext, xgettext-not-found) AC_PATH_PROG(MSGMERGE, msgmerge, msgmerge-not-found) +AC_PATH_PROG(JQ, jq, no) +if test ! -x "$JQ"; then + AC_MSG_ERROR(jq not found - cannot get version from META6.json without it) +fi +AC_PATH_PROG(TR, tr, no) +if test ! -x "$TR"; then + AC_MSG_ERROR(tr not found - cannot get version from META6.json without it) +fi URL_CAT="neither curl nor wget found" @@ -148,11 +156,11 @@ fi AC_ARG_VAR(RAKULIB, [Colon separated list of raku library directories]) AC_SUBST(RAKULIB) -# lib/Makefile -# bin/Makefile AC_CONFIG_FILES([ Makefile etc/Makefile + bin/Makefile + lib/Makefile frontend/Makefile thirdparty/Makefile ]) @@ -182,8 +190,8 @@ if test "$mod_ok" = "0"; then ** SOME PERL MODULES ARE MISSING ****************************** -If you know where perl can find the missing modules, set -the RAKULIB environment variable accordingly. Otherwise +If you know where raku can find the missing modules, set +the PERL5LIB environment variable accordingly. Otherwise just proceed and the missing modules will be installed automatically. diff --git a/lib/Agrammon/OutputFormatter/ExcelFast.pm6 b/lib/Agrammon/OutputFormatter/ExcelFast.pm6 deleted file mode 100644 index ccfa01d7..00000000 --- a/lib/Agrammon/OutputFormatter/ExcelFast.pm6 +++ /dev/null @@ -1,166 +0,0 @@ -use v6; -use Agrammon::Config; -use Agrammon::Model; -use Agrammon::Outputs; -use Agrammon::OutputFormatter::CollectData; -use Agrammon::Timestamp; -use Agrammon::Web::SessionUser; -#use Spreadsheet::XLSX; -#use Spreadsheet::XLSX::Styles; - -use Temp::Path; -use Excel::Writer::XLSX:from; - -sub input-output-as-excel( - Agrammon::Config $cfg, - $user, - Str $dataset-name, Agrammon::Model $model, - Agrammon::Outputs $outputs, Agrammon::Inputs $inputs, $reports, - Str $language, Int $report-selected, - Bool $include-filters, Bool $all-filters -) is export { - - my $temp-file = make-temp-path :suffix<.xlsx>; - my $workbook = Excel::Writer::XLSX.new($temp-file.absolute); - - # prepare sheets - my $output-sheet = $workbook.add_worksheet('Ergebnisse'); - my $output-sheet-formatted = $workbook.add_worksheet('Ergebnisse formatiert'); - my $input-sheet = $workbook.add_worksheet('Eingaben'); - my $input-sheet-formatted = $workbook.add_worksheet('Eingaben formatiert'); - - my $timestamp = timestamp; - my $model-version = $cfg.gui-title{$language} ~ " - " ~ $cfg.gui-variant; - - # set column width - for ($output-sheet, $output-sheet-formatted) -> $sheet { - $sheet.set_column(0, 0, 20); - $sheet.set_column(1, 1, 32); - $sheet.set_column(2, 2, 20); - $sheet.set_column(3, 3, 10); - - } - - $input-sheet.set_column(0, 0, 30); - $input-sheet.set_column(1, 1, 20); - $input-sheet.set_column(2, 3, 50); - $input-sheet.set_column(4, 4, 10); - - $input-sheet-formatted.set_column(0, 0, 10); - $input-sheet-formatted.set_column(1, 2, 50); - $input-sheet-formatted.set_column(3, 3, 10); - - my $bold-format = $workbook.add_format(); - $bold-format.set_bold(); - - my $number-format = $workbook.add_format(); - $number-format.set_num_format( '0.000' ); - - my $number-format-short = $workbook.add_format(); - $number-format-short.set_num_format( '0.0' ); - - my $number-format-right = $workbook.add_format(); - $number-format-right.set_num_format( '0.000' ); - $number-format-right.set_align( 'right' ); - - my $number-format-right-short = $workbook.add_format(); - $number-format-right-short.set_num_format( '0.0' ); - $number-format-right-short.set_align( 'right' ); - - for ($output-sheet-formatted, $input-sheet-formatted) -> $sheet { - $sheet.write(0, 0, $dataset-name, $bold-format); - $sheet.write(1, 0, $user.username); - $sheet.write(2, 0, $model-version); - $sheet.write(3, 0, $timestamp); - } - - for ($output-sheet, $input-sheet) -> $sheet { - $sheet.write(0, 2, $dataset-name); - $sheet.write(1, 2, $user.username); - $sheet.write(2, 2, $model-version); - $sheet.write(3, 2, $timestamp); - } - - # prepared data - my %data = collect-data( - $model, - $outputs, $inputs, $reports, - $language, $report-selected, - $include-filters, $all-filters - ); - - my @records; - # TODO: fix sorting - my $col = 0; - my $row = 5; - my $row-formatted = $row; - my $last-print = ''; -# for @records.sort(+*.) -> %rec { - my $last-instance = ''; - my $last-module = ''; - @records := %data; - note "inputs: " ~ @records.elems if %*ENV; - for @records -> %rec { - - # raw data - $input-sheet.write($row, $col+0, %rec); - $input-sheet.write($row, $col+1, %rec); - $input-sheet.write($row, $col+2, %rec); - $input-sheet.write($row, $col+3, (%rec // '???'), $number-format-right); - $input-sheet.write($row, $col+4, %rec); - $row++; - - # formatted data - my $instance = %rec; - my $module = %rec; - if $module ne $last-module { - $input-sheet-formatted.write($row-formatted, $col+0, $module, $bold-format); - $row-formatted++; - $last-module = $module; - } - if $instance and $instance ne $last-instance { - $input-sheet-formatted.write($row-formatted, $col+1, $instance, $bold-format); - $row-formatted++; - $last-instance = $instance; - } - $input-sheet-formatted.write($row-formatted, $col+1, %rec); - $input-sheet-formatted.write($row-formatted, $col+2, (%rec // '???'), $number-format-right-short); - $input-sheet-formatted.write($row-formatted, $col+3, %rec); - $row-formatted++; - } - - # add outputs - my %print-labels = %data; - - @records := %data; - note "outputs: " ~ @records.elems if %*ENV; - $row = 5; - $row-formatted = $row; - $col = 0; - $last-print = ''; - - for @records.sort(+*.) -> %rec { - my $print = %rec; # can be undefined or empty - $output-sheet.write($row, $col+0, %print-labels{$print}{$language} // '') if $print; - $output-sheet.write($row, $col+1, %rec