Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions category_def.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ geo:
detail:
subject:
title:
en: Subject archives folders
de: Sacharchiv Mappen
en: Subject archives
de: Sacharchiv
ware:
title:
en: Commodities/wares archives folders
de: Warenarchiv Mappen
en: Commodities/wares archives
de: Warenarchiv
subject:
prov: hwwa
title:
Expand All @@ -22,8 +22,8 @@ subject:
detail:
geo:
title:
en: Countries-subject archives folders
de: Länder-Sacharchiv Mappen
en: Countries-subject archives
de: Länder-Sacharchiv
ware:
prov: hwwa
title:
Expand All @@ -33,5 +33,5 @@ ware:
detail:
geo:
title:
en: Commodities/wares archives folders
de: Warenarchiv Mappen
en: Commodities/wares archives
de: Warenarchiv
33 changes: 26 additions & 7 deletions create_category_pages.pl
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@
$category_type eq 'ware'
? $firstletter
: $master_voc->subheading( $lang, $firstletter );
push( @lines, '', "### $subhead <a name='id_$firstletter'></a>", '' );
push( @lines, '', "#### $subhead <a name='id_$firstletter'></a>",
'' );
push( @tabs, { startchar => $firstletter } );
$firstletter_old = $firstletter;
}
Expand Down Expand Up @@ -317,6 +318,19 @@
#
###########################

# data structure %category_data:

# category_type
# category_id # defines page
# detail_type
# folder
# lines
# de|en
# filming_loop
# de|en
# filming
# filmsection_loop

my %category_data;

print "\nCollect data for folders\n";
Expand Down Expand Up @@ -460,7 +474,7 @@
# prepend subheading
my $subheading =
$detail_voc->subheading( $lang, $firstletter ) || $firstletter;
$text .= "\n\n### $subheading\n\n";
$text .= "\n\n#### $subheading\n\n";

# all text line for this subheading
$text .= join( "\n", @{ $lines_ref->{$firstletter} } );
Expand All @@ -479,8 +493,8 @@

print "\n\nCollect data for film sections\n";

# only top level for the country-subject and ware archives
foreach my $category_type (qw/ geo ware /) {
# now for all top level pages
foreach my $category_type (qw/ geo subject ware /) {
print "\nfilm sections category_type: $category_type\n";

# master vocabulary reference
Expand All @@ -493,7 +507,6 @@
my @detail_types =
sort keys %{ $definitions_ref->{$category_type}{detail} };
foreach my $detail_type (@detail_types) {
next if $category_type eq 'geo' and $detail_type eq 'ware';

print " detail_type: $detail_type\n";
my $def_ref = $definitions_ref->{$category_type}->{detail}{$detail_type};
Expand All @@ -507,17 +520,21 @@
foreach my $filming (qw/ 1 2 /) {
my $filming_ref = $filming_def_ref->{$filming};

# filmsections for the master / detail combination (works in either
# normal or inversed hierarchical order)
my @filmsectionlist =
$master_voc->filmsectionlist( $category_id, $filming );
$master_voc->filmsectionlist( $category_id, $filming,
$detail_type );

# how to deal deal wth mission information depends ...
# how to deal deal with missing information depends ...
if ( not scalar(@filmsectionlist) > 0 ) {
if ( $filming eq '1'
and $category_data{$category_type}{$category_id}{$detail_type}
{folder}{complete} )
{
## is ok
} else {
## in which cases should a warning be issued?
## warn "no film data for $category_id in filming $filming\n";
}
next;
Expand Down Expand Up @@ -558,6 +575,7 @@
}

###print "\n## size inc. film: ", total_size(\%category_data) / (1024*1024), "\n";
###print Dumper \%category_data; exit;

print "\n\nOutput of individual category pages\n\n";

Expand Down Expand Up @@ -617,6 +635,7 @@ sub output_category_page {
$PROV{ $definitions_ref->{$category_type}{prov} }{name}{$lang};
my $signature = $master_voc->signature($id);
my $label = $master_voc->label( $lang, $id );
$label =~ s/"/\\"/g;
my $backlinktitle =
$lang eq 'en'
? 'Category Overview'
Expand Down
18 changes: 15 additions & 3 deletions html_tmpl/category.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ Scope Note: <tmpl_var scope_note><tmpl_if is_en></tmpl_if>
</div></tmpl_if></tmpl_if>

<tmpl_if show_tabs>
<tmpl_if is_de>[Sacharchiv](#sacharchiv-mappen) &#160; [Warenarchiv](#warenarchiv-mappen)</tmpl_if>
<tmpl_if is_en>[Subject archives](#subject-archives-folders) &#160; [Commodities/wares archives](#commoditieswares-archives-folders)</tmpl_if>
<tmpl_if is_de>[Sacharchiv](#sacharchiv) &#160; [Warenarchiv](#warenarchiv)</tmpl_if>
<tmpl_if is_en>[Subject archives](#subject-archives) &#160; [Commodities/wares archives](#commoditieswares-archives)</tmpl_if>
</tmpl_if>

<tmpl_loop detail_type_loop>

## <tmpl_var detail_title>

### <tmpl_if is_de>Mappen</tmpl_if><tmpl_if is_en>Folders</tmpl_if>

<tmpl_if detail_is_geo>

<tmpl_if lines>
Expand Down Expand Up @@ -85,6 +87,8 @@ _For direct access to the documents, click the "(xy documents)" link, for folder

<tmpl_if detail_is_ware>

<tmpl_if lines>

<tmpl_if is_de>
Insgesamt <tmpl_var folder_count1> Mappen (bis 1949), <tmpl_var document_count1> Dokumente
- Mappen unvollständig. Nicht als Mappe aufbereitetes Material finden Sie
Expand All @@ -104,6 +108,14 @@ _For direct access to the documents, click the "(xy documents)" link, for folder

<tmpl_var lines>

</tmpl_if detail_is_subject>
<tmpl_else>

<tmpl_if is_de>Kein als Mappe erschlossenes Material.</tmpl_if><tmpl_if is_en>No material prepared as folder.</tmpl_if>

</tmpl_if lines>

<tmpl_include name="filmsections.md.inc">

</tmpl_if detail_is_ware>

</tmpl_loop detail_type_loop>
2 changes: 1 addition & 1 deletion html_tmpl/filmsections.md.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<a id="filmsections" />
<tmpl_loop filming_loop>
## <tmpl_var filming_title>
### <tmpl_var filming_title>

<p><tmpl_var legal></p>

Expand Down
98 changes: 91 additions & 7 deletions lib/ZBW/PM20x/Film.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ Readonly my $IMG_COUNT => _init_img_count();

# items in a collection are primarily grouped by $type, identified by zotero
# or filmlist properties
# CAUTION: for geo categories, subject, ware and company categories are related!
Readonly my %GROUPING_PROPERTY => (
co => {
## ignore countries for now!
## ignore countries for now! (logically primary category for companies?)
primary_group => {
type => 'company',
zotero => 'pm20Id',
Expand All @@ -43,6 +44,7 @@ Readonly my %GROUPING_PROPERTY => (
type => 'geo',
zotero => 'geo_id',
filmlist => 'start_company_id',
jsonld => 'country',
rdf_pred => 'zbwext:country',
rdf_prefix => 'pm20geo',
},
Expand All @@ -59,6 +61,7 @@ Readonly my %GROUPING_PROPERTY => (
secondary_group => {
type => 'subject',
zotero => 'subject_id',
jsonld => 'subject',
rdf_pred => 'zbwext:subject',
rdf_prefix => 'pm20subject',
},
Expand All @@ -69,9 +72,10 @@ Readonly my %GROUPING_PROPERTY => (
# $SECTION = { $section_uri => { img_count, ...} }
# $FOLDER = { $collection => { $folder_nk => { $filming => [ $section_uri, ... ] } } }
# $CATEGORY = { $category_type => { $category_id => { $filming => [ $section_uri ... ] } } }
# $CATEGORY_INV = { $type => { $secondary_category_id => { $filming => [ $section_uri ... ] } } }
# DOES NOT WORK WITH Readonly!
##Readonly my ( $FILM, $SECTION, $FOLDER, $CATEGORY ) => _load_filmdata();
my ( $FILM, $SECTION, $FOLDER, $CATEGORY ) = _load_filmdata();
my ( $FILM, $SECTION, $FOLDER, $CATEGORY, $CATEGORY_INV ) = _load_filmdata();

=encoding utf8

Expand Down Expand Up @@ -232,8 +236,22 @@ sub foldersections {

=item categorysections ($category_type, $category_id, $filming)

Return a list of film sections for the category, for a certain filming (1|2).
Currently, only works for the primary category. (geo for sh, ware for wa)
Return a list of film sections of type secondary for a certain primary category, for a
certain filming (1|2).

Valid $category_type are:

=over 2

=item *

geo - retrieves a list of subject entries for this geo

=item *

ware - retrieves a list of geo entries for this ware

=back

=cut

Expand All @@ -245,6 +263,9 @@ sub categorysections {

my @sectionlist;

croak("wrong category type $category_type")
unless $category_type =~ m/^(geo|ware)$/;

# $CATEGORY = { $category_type => { $category_id => { $filming => [ $section_uri ... ] } } }
foreach
my $section_uri ( @{ $CATEGORY->{$category_type}{$category_id}{$filming} } )
Expand All @@ -255,6 +276,48 @@ sub categorysections {
return @sectionlist;
}

=item categorysections_inv ($category_type, $category_id, $filming)

Inversely, return a list of film sections of type primary for a certain
secondary category, for a certain filming (1|2).

Valid $category_type are:

=over 4

=item *

geo - retrieves a list of ware entries for this geo

=item *

subject - retrieves a list of geo entries for this subject

=back

=cut

sub categorysections_inv {
my $class = shift or croak('param missing');
my $category_type = shift or croak('param missing');
my $category_id = shift or croak('param missing');
my $filming = shift or croak('param missing');

croak("wrong category type $category_type")
unless $category_type =~ m/^(geo|subject)$/;

my @sectionlist;

# $CATEGORY_INV = { $category_type => { $category_id => { $filming => [ $section_uri ... ] } } }
foreach my $section_uri (
@{ $CATEGORY_INV->{$category_type}{$category_id}{$filming} } )
{
my %entry = ( $section_uri => $SECTION->{$section_uri}, );
push( @sectionlist, $SECTION->{$section_uri} );
}
return @sectionlist;
}

=back

=head1 Instance methods
Expand Down Expand Up @@ -292,7 +355,7 @@ sub logical_name {

=item sections ()

Return a list of film sections for a film.
Return a list of film sections for a film.

=cut

Expand All @@ -314,7 +377,7 @@ sub sections {

=item img_count ()

Return the numer of images files under the film directory.
Return the numer of image files under the film directory.

=cut

Expand Down Expand Up @@ -396,6 +459,7 @@ sub _load_filmdata {

# categories
else {
# primary group
my $grp_prop_ref = ZBW::PM20x::Film->get_grouping_properties($collection);
my $category_type = $grp_prop_ref->{primary_group}{type};
my $category_prop = $grp_prop_ref->{primary_group}{jsonld};
Expand All @@ -410,9 +474,29 @@ sub _load_filmdata {
$section_uri
);
}

next unless $grp_prop_ref->{secondary_group};

# secondary group
my $secondary_category_type = $grp_prop_ref->{secondary_group}{type};
my $secondary_category_prop = $grp_prop_ref->{secondary_group}{jsonld};

if ( $section_ref->{$secondary_category_prop}
and my $category_uri = $section_ref->{$secondary_category_prop}{'@id'} )
{
$category_uri =~ m;category/$secondary_category_type/i/(\d{6});;
my $secondary_category_id = $1;
push(
@{
$CATEGORY_INV->{$secondary_category_type}{$secondary_category_id}
{$filming}
},
$section_uri
);
}
}
}
return $FILM, $SECTION, $FOLDER, $CATEGORY;
return $FILM, $SECTION, $FOLDER, $CATEGORY, $CATEGORY_INV;
}

1;
Expand Down
Loading