Changeset 2551

Show
Ignore:
Timestamp:
02/26/10 17:10:55 (5 months ago)
Author:
JensDiemer
Message:

plugin can change the permalink, e.g. to a detail view.
more info: http://www.pylucid.org/permalink/319/about-permalink-for-plugin-developers

Location:
branches/0.9/pylucid_project
Files:
2 added
9 modified

Legend:

Unmodified
Added
Removed
  • branches/0.9/pylucid_project/apps/pylucid/context_processors.py

    r2539 r2551  
     1# coding: utf-8 
    12 
    23""" 
  • branches/0.9/pylucid_project/apps/pylucid/views.py

    r2549 r2551  
    1111from pylucid_project.system.pylucid_plugins import PYLUCID_PLUGINS 
    1212 
    13 from pylucid.markup.converter import apply_markup 
    14 from pylucid.signals import pre_render_global_template 
    15 from pylucid.system import pylucid_plugin, i18n, pylucid_objects 
    16 from pylucid.models import PageTree, PageMeta, PageContent, PluginPage, ColorScheme, \ 
     13from pylucid_project.apps.pylucid.markup.converter import apply_markup 
     14from pylucid_project.apps.pylucid.signals import pre_render_global_template 
     15from pylucid_project.apps.pylucid.system import pylucid_plugin, i18n, pylucid_objects 
     16from pylucid_project.apps.pylucid.models import PageTree, PageMeta, PageContent, PluginPage, ColorScheme, \ 
    1717                                                                    EditableHtmlHeadFile, Language 
    1818 
     
    339339    url = pagemeta.get_absolute_url() 
    340340 
     341    if pagetree.page_type == pagetree.PLUGIN_TYPE and url_rest and "/" in url_rest: 
     342        # pass a permalink additional to the plugin, e.g.: blog entry detail view 
     343        additional_url = url_rest.split("/", 1)[1] 
     344        url += additional_url 
     345 
    341346    return http.HttpResponseRedirect(url) 
    342347 
  • branches/0.9/pylucid_project/middlewares/headline_anchor.py

    r2549 r2551  
    117117 
    118118        # Get the permalink to the current page 
    119         permalink = pagemeta.get_permalink() 
     119        permalink = request.PYLUCID.context["page_permalink"] 
     120#        permalink = pagemeta.get_permalink() 
    120121 
    121122        # insert the Headline links 
  • branches/0.9/pylucid_project/pylucid_plugins/blog/models.py

    r2527 r2551  
    3030 
    3131from pylucid_project.apps.pylucid.shortcuts import failsafe_message 
     32from pylucid_project.apps.pylucid.markup.converter import apply_markup 
     33from pylucid_project.apps.pylucid.cache import clean_complete_pagecache 
     34from pylucid_project.apps.pylucid.system.permalink import plugin_permalink 
    3235from pylucid_project.apps.pylucid.models import PageContent, Language, PluginPage 
    33 from pylucid_project.apps.pylucid.markup.converter import apply_markup 
    3436from pylucid_project.apps.pylucid.models.base_models import AutoSiteM2M, UpdateInfoBaseModel 
    35 from pylucid_project.apps.pylucid.cache import clean_complete_pagecache 
    3637 
    3738from pylucid_project.pylucid_plugins import update_journal 
     
    164165                return "#No-Blog-PagePlugin-exists" 
    165166 
     167    def get_permalink(self, request): 
     168        """ permalink to this entry detail view """ 
     169        absolute_url = self.get_absolute_url() # Absolute url to this entry 
     170        permalink = plugin_permalink(request, absolute_url) 
     171        return permalink 
     172 
    166173    def get_html(self): 
    167174        """ 
  • branches/0.9/pylucid_project/pylucid_plugins/blog/templates/blog/detail_view.html

    r2538 r2551  
    77 
    88<fieldset class="entry"> 
    9     <legend class="headline"> 
    10          <a href="{{ entry.get_absolute_url }}">{{ entry.headline }}<br /> 
    11          <small class="headline_info">{% blocktrans with entry.createtime|timesince as time %}Before {{ time }} published by{% endblocktrans %} {{ entry.createby }}.</small> 
    12          </a> 
    13     </legend> 
    14  
    15     {% if not entry.is_public %} 
    16         <p class="admin_info_line">not public</p> 
    17     {% endif %} 
    18      
    19     {% include "blog/includes/admin_links.html" %} 
    20      
    21     <div class="content">{{ entry.get_html }}</div> 
    22      
    23     {% if entry.lastupdateby %} 
    24     <small><p class="date_info"> 
    25         (Last update: {{ entry.lastupdatetime|date:_("DATETIME_FORMAT") }} by {{ entry.lastupdateby }}.) 
    26     </p></small> 
    27     {% endif %} 
    28      
    29     {% include "blog/includes/taglist.html" %} 
    30      
     9    {% include "blog/includes/blog_entry.html" %} 
    3110    {% include "pylucid_comments/includes/comments_list.html" %} 
    3211</fieldset> 
  • branches/0.9/pylucid_project/pylucid_plugins/blog/templates/blog/summary.html

    r2538 r2551  
    99{% for entry in entries.object_list %} 
    1010<fieldset class="entry"> 
    11     <legend class="headline"> 
    12          <a href="{{ entry.get_absolute_url }}">{{ entry.headline }}<br /> 
    13          <small class="headline_info">{% blocktrans with entry.createtime|timesince as time %}Before {{ time }} published by{% endblocktrans %} {{ entry.createby }}.</small> 
    14          </a> 
    15     </legend> 
    16     {% if not entry.is_public %} 
    17         <p class="admin_info_line">not public</p> 
    18     {% endif %} 
    19  
    20     {% include "blog/includes/admin_links.html" %} 
    21  
    22     <div class="content">{{ entry.get_html }}</div> 
    23  
    24     {% if entry.lastupdateby %} 
    25     <small><p class="date_info"> 
    26         (Last update: {{ entry.lastupdatetime|date:_("DATETIME_FORMAT") }} by {{ entry.lastupdateby }}.) 
    27     </p></small> 
    28     {% endif %} 
    29  
    30    {% include "blog/includes/taglist.html" %} 
    31  
    32    {% get_comment_count for entry as comment_count %}             
    33    <a href="{{ entry.get_absolute_url }}" class="comment_link" title="Display all comments | Leave a comment">{{ comment_count }} comment{{ comment_count|pluralize:"s" }}...</a> 
    34  
     11        {% include "blog/includes/blog_entry.html" %} 
     12        {% get_comment_count for entry as comment_count %}             
     13        <a href="{{ entry.get_absolute_url }}" class="comment_link" title="Display all comments | Leave a comment">{{ comment_count }} comment{{ comment_count|pluralize:"s" }}...</a> 
    3514</fieldset> 
    3615{% endfor %} 
  • branches/0.9/pylucid_project/pylucid_plugins/blog/views.py

    r2546 r2551  
    141141 
    142142    tag_cloud = BlogEntry.objects.get_tag_cloud(request) 
     143 
     144#    request.context["page_permalink"] = "YYYY" 
    143145 
    144146    context = { 
     
    224226    tag_cloud = BlogEntry.objects.get_tag_cloud(request) 
    225227 
     228    # Change permalink from the blog root page to this entry detail view 
     229    permalink = entry.get_permalink(request) 
     230    request.PYLUCID.context["page_permalink"] = permalink # for e.g. the HeadlineAnchor 
     231 
    226232    context = { 
    227233        "page_title": entry.headline, # Change the global title with blog headline 
     
    229235        "tag_cloud": tag_cloud, 
    230236        "CSS_PLUGIN_CLASS_NAME": settings.PYLUCID.CSS_PLUGIN_CLASS_NAME, 
     237        "page_permalink": permalink, # Change the permalink in the global page template 
    231238    } 
    232239    return context 
  • branches/0.9/pylucid_project/pylucid_plugins/lexicon/models.py

    r2330 r2551  
    2727from pylucid_project.pylucid_plugins import update_journal 
    2828 
    29 from pylucid.shortcuts import failsafe_message 
    30 from pylucid.markup.converter import apply_markup 
    31 from pylucid.models import PageContent, Language 
    32 from pylucid.models.base_models import AutoSiteM2M, UpdateInfoBaseModel 
     29from pylucid_project.apps.pylucid.shortcuts import failsafe_message 
     30from pylucid_project.apps.pylucid.markup.converter import apply_markup 
     31from pylucid_project.apps.pylucid.models import PageContent, Language 
     32from pylucid_project.apps.pylucid.system.permalink import plugin_permalink 
     33from pylucid_project.apps.pylucid.models.base_models import AutoSiteM2M, UpdateInfoBaseModel 
    3334#from PyLucid.tools.content_processors import apply_markup, fallback_markup 
    3435#from PyLucid.models import Page 
     
    112113                return "?lexicon=%s" % self.term 
    113114 
     115    def get_permalink(self, request): 
     116        """ permalink to this entry detail view """ 
     117        absolute_url = self.get_absolute_url() # Absolute url to this entry 
     118        permalink = plugin_permalink(request, absolute_url) 
     119        return permalink 
     120 
    114121    def get_html(self): 
    115122        """ 
  • branches/0.9/pylucid_project/pylucid_plugins/lexicon/views.py

    r2391 r2551  
    8888    _add_breadcrumb(request, title="%s: %s" % (entry.term, entry.short_definition), url=request.path) 
    8989 
    90     context = {"entry": entry} 
     90    # Change permalink from the blog root page to this entry detail view 
     91    permalink = entry.get_permalink(request) 
     92    request.PYLUCID.context["page_permalink"] = permalink # for e.g. the HeadlineAnchor 
     93 
     94    context = { 
     95        "entry": entry, 
     96        "page_permalink": permalink, # Change the permalink in the global page template 
     97    } 
    9198    return context 
    9299