File size: 2,978 Bytes
ae01f49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2024, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################

"""A blueprint module implementing the pgAdmin help system."""
from flask import url_for
from flask_babel import gettext
from pgadmin.utils import PgAdminModule
from pgadmin.utils.menu import MenuItem, Panel
from pgadmin.utils.preferences import Preferences
import config

MODULE_NAME = 'help'


class HelpModule(PgAdminModule):
    def get_own_menuitems(self):
        """Return a (set) of dicts of help menu items, with name, priority,
        URL, target and onclick code."""
        return {'help_items': [
            MenuItem(name='mnu_quick_search_help',
                     label=gettext('Quick Search'),
                     priority=99,
                     target='pgadmin_quick_search_help',
                     icon='fa fa-question',
                     url='#'),
            MenuItem(name='mnu_online_help',
                     label=gettext('Online Help'),
                     priority=100,
                     target='pgadmin_help',
                     icon='fa fa-question',
                     url=url_for('help.static', filename='index.html')),

            MenuItem(name='mnu_pgadmin_website',
                     label=gettext('pgAdmin Website'),
                     priority=200,
                     target='pgadmin_website',
                     icon='fa fa-external-link-alt',
                     url='https://www.pgadmin.org/'),

            MenuItem(name='mnu_postgresql_website',
                     label=gettext('PostgreSQL Website'),
                     priority=300,
                     target='postgres_website',
                     icon='fa fa-external-link-alt',
                     url='https://www.postgresql.org/')]}

    def register_preferences(self):
        """
        register_preferences
        Register preferences for this module.
        """
        # Register options for the PG and PPAS help paths
        self.help_preference = Preferences('paths', gettext('Paths'))

        self.pg_help_path = self.help_preference.register(
            'help', 'pg_help_path',
            gettext("PostgreSQL Help Path"), 'text',
            'https://www.postgresql.org/docs/$VERSION$/',
            category_label=gettext('Help'),
            help_str=gettext(
                'Path to the PostgreSQL documentation. $VERSION$ will be '
                'replaced with the major.minor version number.'
            )
        )

    def get_exposed_url_endpoints(self):
        """
        Returns the list of URLs exposed to the client.
        """
        return ['help.static']


# Initialise the module
blueprint = HelpModule(
    MODULE_NAME, __name__,
    static_url_path='/help',
    static_folder=config.HELP_PATH
)