44
55import ckan .plugins as p
66import ckan .plugins .toolkit as tk
7- import ckan .types as types
7+ from ckan import types
8+ from ckan .common import CKANConfig
89from ckan .types import Context , DataDict
910
1011import ckanext .pygments .cache as pygment_cache
@@ -25,7 +26,7 @@ class PygmentsPlugin(p.SingletonPlugin):
2526
2627 # IConfigurer
2728
28- def update_config (self , config_ ) :
29+ def update_config (self , config_ : CKANConfig ) -> None :
2930 tk .add_template_directory (config_ , "templates" )
3031 tk .add_resource ("assets" , "pygments" )
3132
@@ -43,9 +44,7 @@ def info(self) -> dict[str, Any]:
4344 }
4445
4546 def can_view (self , data_dict : DataDict ) -> bool :
46- return pygment_config .is_format_supported (
47- data_dict ["resource" ].get ("format" , "" ).lower ()
48- )
47+ return pygment_config .is_format_supported (data_dict ["resource" ].get ("format" , "" ).lower ())
4948
5049 def view_template (self , context : Context , data_dict : DataDict ) -> str :
5150 return "pygments/pygment_preview.html"
@@ -54,12 +53,9 @@ def form_template(self, context: Context, data_dict: DataDict) -> str:
5453 return "pygments/pygment_form.html"
5554
5655 def setup_template_variables (self , context : Context , data_dict : DataDict ) -> None :
57- data_dict ["resource_view" ].setdefault (
58- "title" , pygment_config .get_default_view_name ()
59- )
60- data_dict ["resource_view" ].setdefault (
61- "description" , pygment_config .get_default_description ()
62- )
56+ data_dict ["resource_view" ].setdefault ("title" , pygment_config .get_default_view_name ())
57+ data_dict ["resource_view" ].setdefault ("description" , pygment_config .get_default_description ())
58+ data_dict ["resource_view" ].setdefault ("show_line_numbers" , pygment_config .get_default_show_line_numbers ())
6359
6460 # IResourceController
6561
0 commit comments