Skip to content

Instantly share code, notes, and snippets.

@tpluscode
Last active September 21, 2023 11:56
Show Gist options
  • Select an option

  • Save tpluscode/a3c3772cc4f0088d0bfb6c53fb8ba467 to your computer and use it in GitHub Desktop.

Select an option

Save tpluscode/a3c3772cc4f0088d0bfb6c53fb8ba467 to your computer and use it in GitHub Desktop.

Revisions

  1. tpluscode revised this gist Sep 21, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion view.ttl
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    # title is simple
    sh:path schema:title ;
    sh:group _:mainGroup ;
    sh:order 1 ;
    sh:order 1 ; # properties are ordered within group
    ], [
    # author concatenates first+last name using SHACL-AF
    sh:path ex:author ;
  2. tpluscode created this gist Sep 21, 2023.
    16 changes: 16 additions & 0 deletions book.ttl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    <book/a-macska-es-a-puding>
    a schema:Book ;
    schema:title "A Macska és a puding" ;
    schema:author [ schema:givenName "Biljana" ; schema:familyName "Nikolic" ] ;
    schema:associatedMedia [
    schema:contentUrl <book/a-macska-es-a-puding.pdf> ;
    ] ;
    schema:image [
    a schema:ImageObject ;
    schema:contentUrl <large-cover> ;
    schema:thumbnail [
    a schema:ImageObject ;
    schema:contentUrl <small-cover> ;
    ] ;
    ] ;
    .
    22 changes: 22 additions & 0 deletions layout.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    <book-layout>
    #shadow-root
    <section id="left">
    <slot name="image"></slot>
    </section>
    <section id="controls">
    <slot name="controls"></slot>
    </section>
    <section id="main">
    <slot></slot>
    </section>

    <!-- main group props go to default slot -->
    <span>A Macska és a puding</span>
    <span>Biljana Nikolic</span>

    <!-- image in slot -->
    <img src="small-cover" alt="?" slot="image" />

    <!-- download button etc -->
    <a href="book/a-macska-es-a-puding.pdf" slot="controls" >
    </book-layout>
    5 changes: 5 additions & 0 deletions page.ttl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    <Page>
    a schema:WebPage ;
    schema:mainEntity <book/a-macska-es-a-puding> ;
    dash:shape <PageShape> ;
    .
    34 changes: 34 additions & 0 deletions view.ttl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    <PageShape>
    a sh:NodeShape ;
    dash:viewer ex:BookLayout ;
    sh:property [
    # title is simple
    sh:path schema:title ;
    sh:group _:mainGroup ;
    sh:order 1 ;
    ], [
    # author concatenates first+last name using SHACL-AF
    sh:path ex:author ;
    sh:values [
    sparql:concat (
    [ sh:path schema:givenName ]
    " "
    [ sh:path schema:familyName ]
    ) ;
    ] ;
    sh:group _:mainGroup ;
    sh:order 2 ;
    ], [
    # image follows the schema:ImageObject to find the thumbnail
    sh:path (schema:image schema:thumbnail schema:contentUrl) ;
    dash:viewer dash:ImageViewer ;
    sh:group _:imageGroup ;
    ], [
    sh:path ( schema:associatedMedia schema:contentUrl ) ;
    ] ;
    .

    _:imageGroup ex:slot "image" .
    _:buttonsGroup ex:slot "controls" .

    # main group does not have a slot, will use default