-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
django cms integration #1
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a2da9bb
[ADD] a simple cms_plugin_processor for django-cms
6f3ac8b
[ADD] cms_plugin : get all definition as definition list
3c6c214
[FIX] don't process term index plugin output
1622ffd
Update terms/cms_plugins.py
jssevestre c95007a
Update terms/cms_plugins.py
jssevestre 50a9855
Update terms/cms_plugin_processors.py
jssevestre 60c8a3e
Update terms/templates/term_plugin.html
jssevestre 732cd6c
Update terms/cms_plugin_processors.py
jssevestre 9e6a9d0
Update terms/cms_plugin_processors.py
jssevestre d554446
Update terms/cms_plugin_processors.py
jssevestre 578739b
Usage note
jssevestre 2ea5f2a
Update README.rst
jssevestre d70125f
Update terms/templates/term_plugin.html
jssevestre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
#-*- coding:utf-8 -*- | ||
|
||
from .html import TermsHTMLReconstructor | ||
from django.template import Context, Template | ||
|
||
|
||
def TermsProcessor(instance, placeholder, rendered_content, original_context): | ||
""" | ||
This processor mark all terms in all placeholders plugins except termsplugins | ||
""" | ||
if 'terms' in original_context: | ||
return rendered_content | ||
|
||
parser = TermsHTMLReconstructor() | ||
parser.feed(rendered_content) | ||
|
||
t = Template('{{ content|safe }}') | ||
c = Context({ | ||
'content': parser.out, | ||
}) | ||
return t.render(c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from cms.plugin_base import CMSPluginBase | ||
from cms.plugin_pool import plugin_pool | ||
from cms.models.pluginmodel import CMSPlugin | ||
from django.utils.translation import ugettext_lazy as _ | ||
from .models import Term | ||
|
||
|
||
class TermsIndexPlugin(CMSPluginBase): | ||
model = CMSPlugin | ||
name = _("Terms Index Plugin") | ||
render_template = "term_plugin.html" | ||
|
||
def render(self, context, instance, placeholder): | ||
terms = Term.objects.all() | ||
context['terms'] = terms | ||
return context | ||
|
||
|
||
plugin_pool.register_plugin(TermsIndexPlugin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<dl class="terms-index"> | ||
{% for term in terms %} | ||
<dt>{{ term|capfirst }}</dt> | ||
<dd>{{ term.definition|safe }} | ||
{% if term.url and term.definition %}<br/>{%endif %} | ||
{{ term.url|urlizetrunc:40 }}</dd> | ||
{% endfor %} | ||
</dl> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized something: if you select every Term, you will also display those who have no definition but a link instead. So you either need to apply a
.exclude(description='')
to this QuerySet or handle this (not so) special case in the template.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO we should add link in the template, maybe a short version like
If there is a description, it will be add after. Else, it will be the only content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good. Maybe a newline this time? Only if there is a url, of course. And maybe more letters shown in the urlizetrunc. Something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, if definition is empty and url not, the new line is still there.
Perhaps, but more complex :
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yes. Sorry. Go on, I think this will be the last one before I merge all your changes.