z_module_indexer (zotonic_core v1.0.0-rc.17)

Implements the module extension mechanisms for scomps, templates, actions etc. Scans all active modules for scomps (etc) and maintains lookup lists for when the system tries to find a scomp (etc).

Summary

Functions

Return a list of all templates, scomps etc per module

Return all indexed files in a module (erlang app). The module does not have to be enabled but must be compiled.

Convert process state when code is changed

Find all dispatch files in all modules and the active site.

Find a scomp, validator etc.

Find a scomp, validator etc.

Scan for all scomps etc. for the context given.

Handling all non call/cast messages

Initiates the server.

Reindex all sites

Reindex the list of all scomps, etc for the site in the context.

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.

Find all .po files in all modules and the active site. This is an active scan, not designed to be fast.

Types

key_type/0

-type key_type() :: template | lib | filter | scomp | action | validator | model | dispatch.

Functions

all(Type, Context)

-spec all(Type, Context) -> ModuleIndexList
             when
                 Type :: key_type(),
                 Context :: z:context(),
                 ModuleIndexList ::
                     [#module_index{key ::
                                        #module_index_key{site :: atom(),
                                                          type ::
                                                              z_module_indexer:key_type() | undefined,
                                                          name ::
                                                              atom() | binary() | {binary(), binary()}},
                                    filepath :: file:filename_all() | undefined,
                                    module :: atom() | undefined,
                                    erlang_module :: atom() | undefined,
                                    tag :: integer() | undefined}].

Return a list of all templates, scomps etc per module

all_files(Type, Module)

-spec all_files(Type, Module) -> ModuleIndexList
                   when
                       Type :: key_type(),
                       Module :: module(),
                       ModuleIndexList ::
                           [#module_index{key ::
                                              #module_index_key{site :: atom(),
                                                                type ::
                                                                    z_module_indexer:key_type() |
                                                                    undefined,
                                                                name ::
                                                                    atom() |
                                                                    binary() |
                                                                    {binary(), binary()}},
                                          filepath :: file:filename_all() | undefined,
                                          module :: atom() | undefined,
                                          erlang_module :: atom() | undefined,
                                          tag :: integer() | undefined}].

Return all indexed files in a module (erlang app). The module does not have to be enabled but must be compiled.

code_change(OldVsn, State, Extra)

Convert process state when code is changed

dispatch(Context)

-spec dispatch(z:context()) -> [{module(), [file:filename_all()]}].

Find all dispatch files in all modules and the active site.

find(What, Name, Context)

-spec find(key_type(), binary() | atom(), z:context()) ->
              {ok,
               #module_index{key ::
                                 #module_index_key{site :: atom(),
                                                   type :: z_module_indexer:key_type() | undefined,
                                                   name :: atom() | binary() | {binary(), binary()}},
                             filepath :: file:filename_all() | undefined,
                             module :: atom() | undefined,
                             erlang_module :: atom() | undefined,
                             tag :: integer() | undefined}} |
              {error, term()}.

Find a scomp, validator etc.

find_all(What, Name, Context)

-spec find_all(key_type(), string() | binary() | atom(), z:context()) ->
                  [#module_index{key ::
                                     #module_index_key{site :: atom(),
                                                       type :: z_module_indexer:key_type() | undefined,
                                                       name :: atom() | binary() | {binary(), binary()}},
                                 filepath :: file:filename_all() | undefined,
                                 module :: atom() | undefined,
                                 erlang_module :: atom() | undefined,
                                 tag :: integer() | undefined}].

Find a scomp, validator etc.

handle_call(Message, From, State)

handle_cast(Message, State)

Scan for all scomps etc. for the context given.

handle_info(Info, State)

Handling all non call/cast messages

index_ref(Context)

init(Site)

Initiates the server.

new_ets()

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

reindex()

-spec reindex() -> ok.

Reindex all sites

reindex(Context)

-spec reindex(z:context()) -> ok.

Reindex the list of all scomps, etc for the site in the context.

start_link(Site)

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

Starts the server

terminate(Reason, State)

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.

translations(Context)

-spec translations(z:context()) -> [{Module :: atom(), [{Language :: atom(), file:filename_all()}]}].

Find all .po files in all modules and the active site. This is an active scan, not designed to be fast.