New modules (addons) — integration notes
Basics
New modules (addons) are extensions points to add extra functionality to Pheix. Technically speaking addons should be just Raku modules.
Addon generic requirements:
- Installation as Raku module via
zef
; - Configuration in
config.json
file; - Each addon should provide
Pheix::Addons::ModuleName
andPheix::Addons::ModuleName::API
.
Breaking changes
$addon
optional argument to fill_seodata()
method:
Add method fill_seodata(Str :$pg_addon, Str $pg_type) {
...
given $pg_type {
when 'debug' {
;
}
when '404' {
%h.append({m => 'Pheix' !!, t => '404'});
}
default {
%h.append(
{
m => ($pg_addon eq q{}) ?? 'Pheix' !! $pg_addon,
t => $pg_type
}
);
}
}
...
}
show_pg
method for Phiex::View::Pages
:
Update - Add
$pg_addon
optional argumentfill_seodata()
method:
method show_pg(
Str :$pg_addon,
Str :$pg_type!,
Str :$pg_route!,
Str :$pg_content,
:%pg_env
) returns Str { ... }
- Call
fill_seodata()
method with$pg_addon
argument:
self.fill_seodata(:pg_addon($pg_addon // 'Pheix'), :pg_type($pg_type));
show_pg()
method in Phiex::View::Pages
:
Update given block at - Make current
default
block aswhen 'debug' { ... }
; - Make
when 'index' { ... }
block asdefault { ... }
; - Update
debug
calls toshow_pg
method (grep -rwn "show_pg"
):
Phiex::Model::JSON
:
Update Add :conf()
arg to group getters:
method get_setting(Str $addon, Str $setting, Str $key, Bool $nocache?, Str :$conf) returns Cool { ... };
method get_group_setting(Str $addon, Str $group, Str $setting, Str $key, Str :$conf) returns Cool { ... };
method get_all_settings_for_group_member(Str $addon, Str $group, Str $setting, Str :$conf) returns Hash { ... };
Module structure
Each addon should has:
-
sharedobj
attr (typeHash
) as a container for sharedobj fromPheix::Controller::Basic
; -
name
attr (typeStr
):
has $.name = 'Weblog';
-
jsonobj
attr (typePheix::Model::JSON
) with module readonly configuration;
has $.jsonob = Pheix::Model::JSON.new(:addonpath('conf/addons')).set_entire_config(:addon($!name));
-
genesis
attr (typeHash
) with module readonly configuration:
has %.genesis =
version => 0.0.1,
routes => $!jsonob.get_all_settings_for_group_member($!name, 'routing', 'routes')
;
- Handler methods (see routes config) for API rendering.
- Method for SEO tag import to configuration at initialization stage
Sample
Private database, SEO tags
Do we need
conf/system/module.tnk
?
More details: #106 (comment 459550707)