forked from DivinumOfficium/divinum-officium
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
code: add Linker.pm (read comment in file)
- use linker in horas, - remove $lang from get ordinarium - getproprium return also source where item was found, do not use %winner2 etc. - add setcomment2 to replace setcomment in all cases - using linker: * monastic_major_responsory * lectio_brevis_prima * getpreces * invitatorium
- Loading branch information
1 parent
8e1e441
commit d6a606e
Showing
8 changed files
with
206 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package DivinumOfficium::Linker; | ||
# use strict; | ||
# use warnings; | ||
|
||
use DivinumOfficium::FileIO qw(do_read); | ||
|
||
BEGIN { | ||
require Exporter; | ||
our $VERSION = 1.00; | ||
our @ISA = qw(Exporter); | ||
our @EXPORT_OK = qw(linker); | ||
} | ||
|
||
|
||
#*** gettext($fname, $section) | ||
# gets text from $section in $fname | ||
# or just $fname content | ||
sub gettext { | ||
my ($fname, $section) = split(/#/, shift, 2); | ||
my $lang = shift; | ||
if (!$section) { | ||
my @a = do_read(main::checkfile($lang, $fname)); | ||
join("\n", @a); | ||
} else { | ||
$fname =~ s/\.txt$//; | ||
my %h = %{main::setupstring($lang, "$fname.txt")}; | ||
$h{$section} =~ s/\n\n//r; | ||
} | ||
} | ||
|
||
#*** linker($ref_to_specials_output, $lang) | ||
# digest output of specials() array of chunks | ||
# chunk cases replaced by | ||
# string @filename#section section from filename | ||
# string @filename contents of filename | ||
# string other leave intact | ||
# array [string, func] 'sources' ammended by 'func' | ||
# string can contain multiple | ||
# 'sources' divided by ";;" (in form | ||
# as two first cases but without @) | ||
# 'func' is called with 'sources' and lang | ||
sub linker { | ||
my(@list) = @{$_[0]}; | ||
my($lang) = $_[1]; | ||
|
||
[ map { | ||
if (ref($_) eq 'ARRAY') { | ||
my @texts = map { gettext($_, $lang) } split(/;;/, $$_[0]); | ||
if (exists($$_[1])) { | ||
&{$$_[1]}(@texts, $lang); | ||
} else { | ||
$text | ||
} | ||
} else { # string | ||
if (substr($_, 0, 1) eq '@') { | ||
gettext(substr($_, 1), $lang) | ||
} else { | ||
$_ | ||
} | ||
} | ||
} @list ]; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.