Skip to content

Commit

Permalink
Rewrote the logic of markdown PARSER, now a must in the settings spec…
Browse files Browse the repository at this point in the history
…ified FLATPAGES_X_PARSER
  • Loading branch information
adw0rd committed Nov 13, 2012
1 parent c48731b commit b7fcade
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
14 changes: 8 additions & 6 deletions flatpages_x/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ def __init__(self,*args,**kwargs):

if latest_revision:
self.fields["content_md"].initial= latest_revision.content_source



def save(self):
fp= super(CustomFlatPageForm, self).save(commit=False)
render_func = curry(load_path_attr(PARSER[0],**PARSER[1]))
fp.content= render_func(self.cleaned_data["content_md"])
fp = super(CustomFlatPageForm, self).save(commit=False)
if PARSER:
render_func = curry(load_path_attr(PARSER[0], **PARSER[1]))
fp.content = render_func(self.cleaned_data["content_md"])
else:
fp.content = self.cleaned_data["content_md"]
fp.save()

r=Revision()
r.flatpage=fp
r.title=fp.title
Expand Down
10 changes: 5 additions & 5 deletions flatpages_x/settings.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.conf import settings

PARSER = getattr(settings, "FLATPAGES_X_PARSER", ["flatpages_x.markdown_parser.parse", {}])
DEFAULT_TEMPLATE_CHOICES=[
('flatpages/default.html','Text Only',),
]
FPX_TEMPLATE_CHOICES=getattr(settings,'FLATPAGES_X_TEMPLATE_CHOICES',DEFAULT_TEMPLATE_CHOICES)
PARSER = getattr(settings, 'FLATPAGES_X_PARSER', None)
DEFAULT_TEMPLATE_CHOICES = [
('flatpages/default.html', 'Text Only', ),
]
FPX_TEMPLATE_CHOICES = getattr(settings, 'FLATPAGES_X_TEMPLATE_CHOICES', DEFAULT_TEMPLATE_CHOICES)


0 comments on commit b7fcade

Please sign in to comment.