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

code_change(OldVsn, State, Extra)

-spec code_change(term(), term(), term()) -> {ok, term()}.

Convert process state when code is changed

expand_mediaclass(Props, Context)

-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_mediaclass_checksum(Checksum)

-spec expand_mediaclass_checksum(list() | binary()) -> {ok, list()} | {error, term()}.

Expand the mediaclass, use the checksum when available

expand_mediaclass_checksum(Checksum, Props)

-spec expand_mediaclass_checksum(Checksum :: binary(), Props :: list()) ->
                                    {ok, list()} | {error, checksum}.

get(MediaClass, Context)

-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.

handle_call(Message, From, State)

handle_cast(Message, State)

-spec handle_cast(term(), term()) ->
                     {noreply, term()} |
                     {noreply, term(), timeout() | hibernate} |
                     {stop, term(), term()} |
                     {stop, term(), term(), timeout() | hibernate}.

handle_info(Info, State)

-spec handle_info(term(), term()) ->
                     {noreply, term()} |
                     {noreply, term(), timeout() | hibernate} |
                     {stop, term(), term()}.

Check every RESCAN_PERIOD msecs if there are changes.

init(Site)

-spec init(term()) -> {ok, term()} | {ok, term(), timeout() | hibernate} | ignore | {stop, term()}.

Initiates the server.

list(Context)

-spec list(Context) -> MediaClasses
              when
                  Context :: z:context(),
                  MediaClasses :: #{ClassName => PreviewProps},
                  ClassName :: binary(),
                  PreviewProps :: proplists:proplist().

Get all mediaclasses for a site.

list(Module, Context)

-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.

module_reindexed(_, Context)

-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

new_ets()

-spec new_ets() -> ets:tid() | atom().

reset(Context)

-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.

start_link(Site)

-spec start_link(term()) -> {ok, pid()} | ignore | {error, term()}.

Starts the server

terminate(Reason, State)

-spec terminate(term(), term()) -> ok.

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.