Changeset 1532

Show
Ignore:
Timestamp:
23.04.2008 09:31:05 (3 weeks ago)
Author:
JensDiemer
Message:
  • page title
    • plugin_manager.handle_command() changes the page title, if it's not changes by the plugin themself.
    • remove some headlines in internal pages
    • set some title in plugins
  • add BasePlugin?.build_menu() - Used in show_internals (comes later)
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pylucid/media/PyLucid/internal_page/admin_menu/sub_menu.html

    r1451 r1532  
    1 <h2>{% trans 'Administration sub menu' %}</h2> 
    2  
    31<fieldset><legend>{% trans 'page admin' %}</legend> 
    42<ul> 
     
    6462        <a href="{{ commandURLprefix }}/filemanager/filelist/">{% trans 'Filemanager' %}</a> 
    6563    </li> 
     64    <li> 
     65        <a href="{{ commandURLprefix }}/show_internals/menu/">{% trans 'Show internals' %}</a> 
     66    </li> 
    6667</ul> 
    6768</fieldset> 
  • trunk/pylucid/media/PyLucid/internal_page/page_admin/delete_pages.html

    r1449 r1532  
    1 <h2>{% trans 'Delete pages' %}</h2> 
    2  
    31<fieldset class="internalpage"> 
    42  <legend>{% trans 'Select pages you will delete:' %}</legend> 
  • trunk/pylucid/media/PyLucid/internal_page/page_admin/select_edit_page.html

    r1449 r1532  
    1 <h2>Edit Page</h2> 
    2  
    31<form name="edit_page" method="post" action="."> 
    42 
  • trunk/pylucid/media/PyLucid/internal_page/page_admin/sequencing.html

    r1449 r1532  
    1 <h2>{% trans 'Sequencing pages' %}</h2> 
    2  
    31<p> 
    42  {% trans 'Here you can change the page position by setting the weights.' %}<br /> 
  • trunk/pylucid/media/PyLucid/internal_page/plugin_admin/administation_menu.html

    r1527 r1532  
    1 <h2>Plugin Administration {{ version }}</h2> 
    2  
    31<table class="plugin_admin"> 
    42    <tr><td class="caption" colspan="7"><h3>not installed</h3></td></tr> 
  • trunk/pylucid/PyLucid/plugins_internal/admin_menu/admin_menu.py

    r1409 r1532  
    1818""" 
    1919 
     20from django.utils.translation import ugettext as _ 
    2021 
    2122from PyLucid.system.BasePlugin import PyLucidBasePlugin 
     
    4344        render the sub menu 
    4445        """ 
     46        # Change the global page title: 
     47        self.context["PAGE"].title = _("Administration sub menu") 
     48 
    4549        is_admin = self.request.user.is_superuser or self.request.user.is_staff 
    4650 
  • trunk/pylucid/PyLucid/plugins_internal/plugin_admin/plugin_admin.py

    r1450 r1532  
    6666        Run the method from a POST and display the menu. 
    6767        """ 
     68        # Change the global page title: 
     69        self.context["PAGE"].title = _("plugin administration") 
     70 
    6871        if self.request.method == 'POST': 
    6972            POST = self.request.POST 
  • trunk/pylucid/PyLucid/system/BasePlugin.py

    r1496 r1532  
    4040from PyLucid.tools.utils import escape 
    4141from PyLucid.system.internal_page import InternalPage, InternalPageNotFound 
     42from PyLucid.system.plugin_manager import get_plugin_config, debug_plugin_config 
     43from PyLucid.models import Plugin 
     44 
    4245 
    4346 
     
    5659 
    5760        self.current_page = self.context["PAGE"] 
     61 
     62    def build_menu(self): 
     63        """ 
     64        Build a simple menu for all plugin methods witch have a "menu_section" 
     65 
     66        Use the internal page template "admin_menu.plugin_menu" ! 
     67 
     68        In the plugin config (plugin_manager_data) must be exist some meta 
     69        information for the menu: 
     70          "menu_section"     : The upper block name 
     71          "menu_description" : Link text (optional, otherewise method name used) 
     72        """ 
     73        plugin = Plugin.objects.get(plugin_name=self.plugin_name) 
     74        plugin_config = get_plugin_config(self.request, 
     75            package_name = plugin.package_name, 
     76            plugin_name = self.plugin_name, 
     77            dissolve_version_string = True, 
     78        ) 
     79#        debug_plugin_config(self.page_msg, plugin_config) 
     80 
     81        plugin_manager_data = plugin_config.plugin_manager_data 
     82 
     83        menu_data = {} 
     84        for method_name, data in plugin_manager_data.iteritems(): 
     85            if not "menu_section" in data: 
     86                continue 
     87 
     88            menu_section = data["menu_section"] 
     89 
     90            if not menu_section in menu_data: 
     91                menu_data[menu_section] = [] 
     92 
     93            menu_data[menu_section].append( 
     94                { 
     95                    "link": self.URLs.methodLink(method_name), 
     96                    "description": data.get("menu_description", method_name), 
     97                } 
     98            ) 
     99 
     100        context = { 
     101            "plugin_name": self.plugin_name, 
     102            "version": plugin_config.__version__, 
     103            "menu_data": menu_data, 
     104        } 
     105 
     106        # Change the internal_page and use them from "admin_menu" plugin. 
     107        plugin_internal_page = self.internal_page 
     108        self.internal_page = InternalPage( 
     109            self.context, plugin_name="admin_menu" 
     110        ) 
     111 
     112        self._render_template("plugin_menu", context)#, debug=False) 
     113 
     114        # change back to the original internal pages from the current plugin. 
     115        self.internal_page = self.internal_page 
     116 
    58117 
    59118    def _debug_context(self, context, template): 
  • trunk/pylucid/PyLucid/system/plugin_manager.py

    r1522 r1532  
    6060    plugin_class = getattr(plugin, plugin_name) 
    6161    return plugin_class 
     62 
     63def debug_plugin_config(page_msg, plugin_config): 
     64    for item in dir(plugin_config): 
     65        if item.startswith("_"): 
     66            continue 
     67        page_msg("'%s':" % item) 
     68        page_msg(getattr(plugin_config, item)) 
    6269 
    6370def get_plugin_config(request, package_name, plugin_name, 
     
    198205def handle_command(context, response, plugin_name, method_name, url_args): 
    199206    """ 
    200     handle a _command url request 
    201     """ 
     207    handle a _command url request. 
     208    If the plugin doesn't change the page title, we set it here. 
     209    """ 
     210    original_page_title = context["PAGE"].title 
     211 
    202212    output = run(context, response, plugin_name, method_name, url_args) 
     213 
     214    if context["PAGE"].title == original_page_title: 
     215        # The plugin doesn't set a page title. 
     216        if plugin_name == method_name or method_name == "lucidTag": 
     217            title = plugin_name 
     218        else: 
     219            title = "%s - %s" % (plugin_name, method_name) 
     220        context["PAGE"].title = title.replace("_", " ") 
    203221 
    204222    return output