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.jsonfile; - Each addon should provide
Pheix::Addons::ModuleNameandPheix::Addons::ModuleName::API.
Breaking changes
Add $addon optional argument to fill_seodata() method:
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
}
);
}
}
...
}
Update show_pg method for Phiex::View::Pages:
- Add
$pg_addonoptional 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_addonargument:
self.fill_seodata(:pg_addon($pg_addon // 'Pheix'), :pg_type($pg_type));
Update given block at show_pg() method in Phiex::View::Pages:
- Make current
defaultblock aswhen 'debug' { ... }; - Make
when 'index' { ... }block asdefault { ... }; - Update
debugcalls toshow_pgmethod (grep -rwn "show_pg"):
Update Phiex::Model::JSON:
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:
-
sharedobjattr (typeHash) as a container for sharedobj fromPheix::Controller::Basic; -
nameattr (typeStr):
has $.name = 'Weblog';
-
jsonobjattr (typePheix::Model::JSON) with module readonly configuration;
has $.jsonob = Pheix::Model::JSON.new(:addonpath('conf/addons')).set_entire_config(:addon($!name));
-
genesisattr (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)
Edited by Konstantin Narkhov