z_mediaclass (zotonic_core v1.0.0-rc.17)
Manage, compile and find mediaclass definitions per context/site.
Summary
Functions
Convert process state when code is changed
Expand the optional mediaclass for tag generation
Expand the mediaclass, use the checksum when available
Fetch the mediaclass definition for the current context.
Check every RESCAN_PERIOD msecs if there are changes.
Initiates the server.
Get all mediaclasses for a site.
Get all mediaclasses defined in a module for a site.
Observer, triggered when there are new module files indexed
Call this to force a re-index and parse of all moduleclass definitions.
Starts the server
This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.
Functions
Convert process state when code is changed
-spec expand_mediaclass(list(), #context{cowreq :: cowboy_req:req() | undefined, cowenv :: cowboy_middleware:env() | undefined, site :: atom(), controller_module :: atom() | undefined, client_id :: binary() | undefined, client_topic :: mqtt_sessions:topic() | undefined, routing_id :: binary() | undefined, acl :: term() | admin | undefined, acl_is_read_only :: boolean(), user_id :: integer() | authenticated | undefined, render_state :: undefined | z_render:render_state(), db :: {atom(), atom()} | undefined, dbc :: pid() | undefined, language :: [atom()], tz :: binary(), props :: map(), depcache :: pid() | atom(), dispatcher :: pid() | atom(), template_server :: pid() | atom(), scomp_server :: pid() | atom(), dropbox_server :: pid() | atom(), pivot_server :: pid() | atom(), module_indexer :: pid() | atom(), translation_table :: atom()}) -> {ok, list()}.
Expand the optional mediaclass for tag generation
Expand the mediaclass, use the checksum when available
-spec get(MediaClass :: list() | binary(), #context{cowreq :: cowboy_req:req() | undefined, cowenv :: cowboy_middleware:env() | undefined, site :: atom(), controller_module :: atom() | undefined, client_id :: binary() | undefined, client_topic :: mqtt_sessions:topic() | undefined, routing_id :: binary() | undefined, acl :: term() | admin | undefined, acl_is_read_only :: boolean(), user_id :: integer() | authenticated | undefined, render_state :: undefined | z_render:render_state(), db :: {atom(), atom()} | undefined, dbc :: pid() | undefined, language :: [atom()], tz :: binary(), props :: map(), depcache :: pid() | atom(), dispatcher :: pid() | atom(), template_server :: pid() | atom(), scomp_server :: pid() | atom(), dropbox_server :: pid() | atom(), pivot_server :: pid() | atom(), module_indexer :: pid() | atom(), translation_table :: atom()}) -> {ok, PreviewProps :: list(), Checksum :: binary()}.
Fetch the mediaclass definition for the current context.
-spec handle_info(term(), term()) -> {noreply, term()} | {noreply, term(), timeout() | hibernate} | {stop, term(), term()}.
Check every RESCAN_PERIOD msecs if there are changes.
Initiates the server.
-spec list(Context) -> MediaClasses when Context :: z:context(), MediaClasses :: #{ClassName => PreviewProps}, ClassName :: binary(), PreviewProps :: proplists:proplist().
Get all mediaclasses for a site.
-spec list(Module, Context) -> MediaClasses when Module :: module(), Context :: z:context(), MediaClasses :: #{ClassName => PreviewProps}, ClassName :: binary(), PreviewProps :: proplists:proplist().
Get all mediaclasses defined in a module for a site.
-spec module_reindexed(module_reindexed, #context{cowreq :: cowboy_req:req() | undefined, cowenv :: cowboy_middleware:env() | undefined, site :: atom(), controller_module :: atom() | undefined, client_id :: binary() | undefined, client_topic :: mqtt_sessions:topic() | undefined, routing_id :: binary() | undefined, acl :: term() | admin | undefined, acl_is_read_only :: boolean(), user_id :: integer() | authenticated | undefined, render_state :: undefined | z_render:render_state(), db :: {atom(), atom()} | undefined, dbc :: pid() | undefined, language :: [atom()], tz :: binary(), props :: map(), depcache :: pid() | atom(), dispatcher :: pid() | atom(), template_server :: pid() | atom(), scomp_server :: pid() | atom(), dropbox_server :: pid() | atom(), pivot_server :: pid() | atom(), module_indexer :: pid() | atom(), translation_table :: atom()}) -> ok.
Observer, triggered when there are new module files indexed
-spec reset(#context{cowreq :: cowboy_req:req() | undefined, cowenv :: cowboy_middleware:env() | undefined, site :: atom(), controller_module :: atom() | undefined, client_id :: binary() | undefined, client_topic :: mqtt_sessions:topic() | undefined, routing_id :: binary() | undefined, acl :: term() | admin | undefined, acl_is_read_only :: boolean(), user_id :: integer() | authenticated | undefined, render_state :: undefined | z_render:render_state(), db :: {atom(), atom()} | undefined, dbc :: pid() | undefined, language :: [atom()], tz :: binary(), props :: map(), depcache :: pid() | atom(), dispatcher :: pid() | atom(), template_server :: pid() | atom(), scomp_server :: pid() | atom(), dropbox_server :: pid() | atom(), pivot_server :: pid() | atom(), module_indexer :: pid() | atom(), translation_table :: atom()}) -> ok.
Call this to force a re-index and parse of all moduleclass definitions.
Starts the server
This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.