SmeeView.Aspects.Logo (SmeeView v0.1.0) View Source

Represents and processes <mdui:Logo> elements in entity metadata as Aspect structs.

The functions in this module are intended to be applied to individual Aspect structs - for extracting and processing collections of these records please use the matching View module.

Link to this section Summary

Functions

Is the URL a data: URL containing the actual logo, rather than a normal HTTP address?

Returns the file format of the image, if known, based on the URL

Is this aspect relevant to the IdP role?

Returns the language of this aspect (as a two letter ISO 639-1 code)

Is the aspect using this language? (two letter ISO 639-1 code)

Returns the URL for this aspect as a parsed URI struct.

Returns the total number of pixels (X x Y)

Returns the associated role for this aspect: :sp, :idp or :all

Returns the shape of the logo (:square, :portrait or :landscape)

Returns the size of the logo as a word. These words are currently arbitrary, from an old application

Is this aspect relevant to the SP role?

Does the logo use a HTTPS URL?

Returns the URL for this aspect, as a text binary

Is this a valid URL? Returns true if the URL can be parsed.

Link to this section Types

Specs

t() :: %SmeeView.Aspects.Logo{
  height: integer(),
  lang: binary(),
  role: atom(),
  url: binary(),
  width: integer()
}

Link to this section Functions

Specs

data?(aspect :: t()) :: boolean()

Is the URL a data: URL containing the actual logo, rather than a normal HTTP address?

Logo.data?(aspect)
# => true

Specs

format(aspect :: t()) :: atom()

Returns the file format of the image, if known, based on the URL

Logo.format(aspect)
# => :png

Specs

idp?(aspect :: t()) :: boolean()

Is this aspect relevant to the IdP role?

Will return true if the aspect has been derived from an IdP role, or is applicable to all roles.

Logo.idp?(aspect)
# => true

Specs

lang(aspect :: t()) :: binary()

Returns the language of this aspect (as a two letter ISO 639-1 code)

If no language code has been set for this aspect then the default language code will be returned.

Logo.lang(aspect)
# => "fr"
Link to this function

lang?(aspect, lang \\ SmeeView.Utils.default_lang())

View Source

Is the aspect using this language? (two letter ISO 639-1 code)

Returns true if the provided code matches that of the aspect.

If no language code has been set for this aspect then the aspect will be assumed to have the default language code.

Logo.lang?(aspect, "en")
# => false

Specs

parsed!(aspect :: t()) :: URI.t()

Returns the URL for this aspect as a parsed URI struct.

If the URI cannot be parsed then an exception will be raised. If you need more control you should either use valid?/1 first, or just use URI.parse/1 yourself.

Logo.parsed!(aspect)
# => %URI{...}

Specs

pixels(aspect :: t()) :: integer()

Returns the total number of pixels (X x Y)

Logo.pixels(aspect)
# => 4096

Specs

role(aspect :: t()) :: atom()

Returns the associated role for this aspect: :sp, :idp or :all

The role type is useful when handling a mixed list of aspects that may be specific to certain roles of an entity.

Logo.role(aspect)
# => :idp

Specs

shape(aspect :: t()) :: atom()

Returns the shape of the logo (:square, :portrait or :landscape)

It's currently rather crude - only exact squares will return :square

Logo.shape(aspect)
# => :landscape

Specs

size(aspect :: t()) :: atom()

Returns the size of the logo as a word. These words are currently arbitrary, from an old application

Sizes are: :tiny, :small, :icon, :default, :medium, :large, :huge and :silly

Logo.size(aspect)
# => :large

Specs

sp?(aspect :: t()) :: boolean()

Is this aspect relevant to the SP role?

Will return true if the aspect has been derived from an SP role, or is applicable to all roles.

Logo.sp?(aspect)
# => false

Specs

tls?(aspect :: t()) :: boolean()

Does the logo use a HTTPS URL?

Logo.tls?(aspect)
# => false

Specs

url(aspect :: t()) :: binary()

Returns the URL for this aspect, as a text binary

Aspects containing URLs are printable and can be converted to strings using Kernel.to_string/1 or interpolated into another string.

Logo.url(aspect)
# => "https://idp.example.com/information"

Specs

valid?(aspect :: t()) :: boolean()

Is this a valid URL? Returns true if the URL can be parsed.

Logo.valid?(aspect)
# => false