Module z_props

Query string processing, property lists and property maps for Zotonic resources.

Copyright © 2020 Marc Worrell

Authors: Marc Worrell (marc@worrell.nl).

Description

Query string processing, property lists and property maps for Zotonic resources.

Data Types

qs_key()

qs_key() = binary()

qs_prop()

qs_prop() = {qs_key(), qs_value()}

qs_value()

qs_value() = binary() | #upload{} | term()

Function Index

extract_languages/1Find all different language codes in the maps.
from_list/1Convert a list for rsc insert and/or update to a map.
from_props/1Transform a proplist from older resources and/or code to a (nested) map.
from_qs/1Combine properties from a form.
from_qs/2Like from_qs/1, except that a specific date is used to fill in any missing date/time parts.
normalize_dates/3Normalize dates, ensure that all dates are in UTC and parsed to Erlang datetime format.
prune_languages/2Check all trans records, remove languages not mentioned.

Function Details

extract_languages/1

extract_languages(Props::map()) -> [atom()]

Find all different language codes in the maps.

from_list/1

from_list(L::list()) -> {ok, #{binary() => term()}}

Convert a list for rsc insert and/or update to a map. The list could be a list of (binary) query args, or a property list with atom keys.

from_props/1

from_props(Ps::proplists:proplist() | undefined) -> map()

Transform a proplist from older resources and/or code to a (nested) map. This knows how to handle nestes lists like the 'blocks' list of lists.

from_qs/1

from_qs(Qs::[qs_prop()]) -> {ok, #{binary() => term()}}

Combine properties from a form. The form consists of a flat list with query string properties. The result is a map which can be used by the rsc and other routines.

The keys can have a special format, specifying how they are processed: If a date/time part is missing then the current UTC date is used to fill the missing parts.

from_qs/2

from_qs(Qs::[qs_prop()], Now::calendar:datetime()) -> {ok, #{binary() => term()}}

Like from_qs/1, except that a specific date is used to fill in any missing date/time parts.

normalize_dates/3

normalize_dates(Props::m_rsc:props(), IsAllDay::boolean(), Tz::binary() | undefined) -> m_rsc:props()

Normalize dates, ensure that all dates are in UTC and parsed to Erlang datetime format.

prune_languages/2

prune_languages(Props::map(), Langs::[atom()]) -> map()

Check all trans records, remove languages not mentioned.


Generated by EDoc