# All files / outline propertyViews.ts

100% Statements 20/20
100% Branches 2/2
100% Functions 2/2
100% Lines 20/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    382x
    2x
    2x

    2x

    10x

    10x
    10x

    10x
    10x
    10x
    10x
    10x
    10x
    10x

    2x
    60x
    60x

    60x
    60x

    60x

     import { ns } from 'solid-ui'
    import viewAsImage from './viewAsImage'
    import viewAsMbox from './viewAsMbox'

    /** some builtin simple views **/

    export function propertyViews (dom) {
      // view that applies to items that are objects of certain properties.
      const views = {
        properties: [],
        defaults: [],
        classes: []
      } // views

      const asImage = viewAsImage(dom)
      const asMbox = viewAsMbox(dom)

      viewsAddPropertyView(views, ns.foaf('depiction').uri, asImage, true)
      viewsAddPropertyView(views, ns.foaf('img').uri, asImage, true)
      viewsAddPropertyView(views, ns.foaf('thumbnail').uri, asImage, true)
      viewsAddPropertyView(views, ns.foaf('logo').uri, asImage, true)
      viewsAddPropertyView(views, ns.schema('image').uri, asImage, true)
      viewsAddPropertyView(views, ns.foaf('mbox').uri, asMbox, true)
      return views
    }

    /** add a property view function **/
    export function viewsAddPropertyView (views, property, pviewfunc, isDefault) {
      if (!views.properties[property]) {
        views.properties[property] = []
      }
      views.properties[property].push(pviewfunc)
      if (isDefault) {
        // will override an existing default!
        views.defaults[property] = pviewfunc
      }
    } // viewsAddPropertyView