5
5
from ckan .lib .plugins import DefaultTranslation
6
6
7
7
8
+ log = __import__ ("logging" ).getLogger (__name__ )
9
+
10
+
11
+
8
12
class MatolabthemePlugin (plugins .SingletonPlugin , DefaultTranslation ):
9
13
plugins .implements (plugins .IConfigurer )
10
14
plugins .implements (plugins .IConfigDeclaration )
@@ -21,18 +25,49 @@ def update_config(self, config_):
21
25
toolkit .add_public_directory (config_ , "public" )
22
26
toolkit .add_resource ("assets" , "matolabtheme" )
23
27
28
+ # IConfigDeclaration
29
+
30
+ def declare_config_options (self , declaration : Declaration , key : Key ):
31
+
32
+ declaration .annotate ("matolabtheme" )
33
+ group = key .ckanext .matolabtheme
34
+ declaration .declare (group .contact_url , "https://github.com/Mat-O-Lab" )
35
+ declaration .declare (
36
+ group .legal_person_md , "legal person name, street number, Zip city, country"
37
+ )
38
+ declaration .declare (
39
+ group .contact_dp_commissioner_email_md ,
40
+ "[[email protected] ](mailto:[email protected] ?subject=dataprotection CKAN)" ,
41
+ )
42
+ declaration .declare (
43
+ group .dsvgo_contact_md ,
44
+ "legal person name, street number, Zip city, country" ,
45
+ )
46
+ option = declaration .declare_bool (group .dark_mode , False )
47
+ option .set_validators ("not_missing boolean_validator" )
48
+ declaration .declare (group .banner_top , "/static/banner_top.png" )
49
+ declaration .declare (group .banner_top_upload , "" )
50
+ declaration .declare (group .clear_banner_top_upload , "" )
51
+ declaration .declare (group .banner_bottom , "/static/banner_bottom.png" )
52
+ declaration .declare (group .banner_bottom_upload , "" )
53
+ declaration .declare (group .clear_banner_bottom_upload , "" )
54
+ declaration .declare (group .attribution_logo , "/static/favicon.png" )
55
+ declaration .declare (group .attribution_logo_upload , "" )
56
+ declaration .declare (group .clear_attribution_logo_upload , "" )
57
+
24
58
def update_config_schema (self , schema ):
25
59
26
60
ignore_missing = toolkit .get_validator ("ignore_missing" )
61
+ bool_val = toolkit .get_validator ("boolean_validator" )
27
62
unicode_safe = toolkit .get_validator ("unicode_safe" )
28
-
63
+ dark_mode = toolkit . config . get ( "ckanext.matolabtheme.dark_mode" )
29
64
schema .update (
30
65
{
31
66
# This is an existing CKAN core configuration option, we are just
32
67
# making it available to be editable at runtime
33
- "ckanext.matolabtheme.dark_mode" : [
34
- ignore_missing ,
35
- ],
68
+ # "ckanext.matolabtheme.dark_mode": [
69
+ # ignore_missing, bool_val
70
+ # ],
36
71
"ckanext.matolabtheme.banner_top" : [
37
72
ignore_missing ,
38
73
unicode_safe ,
@@ -71,38 +106,9 @@ def update_config_schema(self, schema):
71
106
],
72
107
}
73
108
)
74
-
75
109
return schema
76
110
77
- # IConfigDeclaration
78
-
79
- def declare_config_options (self , declaration : Declaration , key : Key ):
80
-
81
- declaration .annotate ("matolabtheme" )
82
- group = key .ckanext .matolabtheme
83
- declaration .declare (group .contact_url , "https://github.com/Mat-O-Lab" )
84
- declaration .declare (
85
- group .legal_person_md , "legal person name, street number, Zip city, country"
86
- )
87
- declaration .declare (
88
- group .contact_dp_commissioner_email_md ,
89
- "[[email protected] ](mailto:[email protected] ?subject=dataprotection CKAN)" ,
90
- )
91
- declaration .declare (
92
- group .dsvgo_contact_md ,
93
- "legal person name, street number, Zip city, country" ,
94
- )
95
- declaration .declare_bool (group .dark_mode , False )
96
- declaration .declare (group .banner_top , "/static/banner_top.png" )
97
- declaration .declare (group .banner_top_upload , "" )
98
- declaration .declare (group .clear_banner_top_upload , "" )
99
- declaration .declare (group .banner_bottom , "/static/banner_bottom.png" )
100
- declaration .declare (group .banner_bottom_upload , "" )
101
- declaration .declare (group .clear_banner_bottom_upload , "" )
102
- declaration .declare (group .attribution_logo , "/static/favicon.png" )
103
- declaration .declare (group .attribution_logo_upload , "" )
104
- declaration .declare (group .clear_attribution_logo_upload , "" )
105
-
111
+
106
112
# ITemplateHelpers
107
113
108
114
def get_helpers (self ):
0 commit comments