diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/TODO | 36 | ||||
-rw-r--r-- | app/books/models.py | 5 | ||||
-rw-r--r-- | app/figments/models.py | 5 | ||||
-rw-r--r-- | app/guide/models.py | 13 | ||||
-rw-r--r-- | app/links/models.py | 12 | ||||
-rw-r--r-- | app/notes/models.py | 8 | ||||
-rw-r--r-- | app/pages/models.py | 4 | ||||
-rw-r--r-- | app/projects/models/base.py | 8 | ||||
-rw-r--r-- | app/projects/models/code.py | 90 | ||||
-rw-r--r-- | app/resume/models.py | 6 | ||||
-rw-r--r-- | app/src/models.py | 39 | ||||
-rw-r--r-- | app/utils/widgets.py | 13 |
12 files changed, 72 insertions, 167 deletions
@@ -1,7 +1,5 @@ universal/ utils: -add markdown pronessor function to utils and replace all markdown calls with that one. - possibly convert to using Pandoc? Python is pretty good, but using Pandoc directly allows for epub, other formats as well. Plus standardized a bit. Add resume, src and figments to project page, possible as top level menu itesms @@ -13,21 +11,33 @@ https://adactio.com/journal/9775 http://brucelawson.github.io/manifest/ https://serviceworker-cookbook.herokuapp.com/ -fix amp support by anitizing html: +fix amp support by sanitizing html: https://github.com/duner/django-bluebox/blob/master/bluebox/converters/sanitizer.py --- -notes +resume -revamp notes to be like my own personal instagram +clean up design of book detail +handle callbacks from paypal to deliver the book and link to files: +https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNandPDTVariables/ + + +redirect lhp: home, book and rss --- -income app: +notes + +revamp notes to be like my own personal instagram +''' +2) test urlize with markdown links +3) parse out markdown wrapped links for twitter +4) CSS +6) Write JavaScript to automatically place map on current location +''' -- add pay_turnaround field for each publisher and show in admin --- @@ -53,15 +63,3 @@ Then resize all images for responsive gallery. Then play with gallery templates and add a template selecter to form. ---- - -resume - -clean up design of book detail -add paypal app and generate button -handle callbacks from paypal to deliver the book and link to files: -https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNandPDTVariables/ - - -redirect lhp: home, book and rss - diff --git a/app/books/models.py b/app/books/models.py index f5a4a04..d6cd9cf 100644 --- a/app/books/models.py +++ b/app/books/models.py @@ -4,8 +4,7 @@ from django.utils.encoding import force_text from django.conf import settings from django.template.defaultfilters import slugify -# http://freewisdom.org/projects/python-markdown/ -import markdown +from utils.widgets import markdown_to_html class Book(models.Model): @@ -59,7 +58,7 @@ class Book(models.Model): def save(self, *args, **kwargs): if self.body_markdown: - self.body_html = markdown.markdown(self.body_markdown, extensions=['extra'], safe_mode=False) + self.body_html = markdown_to_html(self.body_markdown) self.slug = slugify(self.title[:50]) super(Book, self).save() diff --git a/app/figments/models.py b/app/figments/models.py index e108e21..b76d8d5 100644 --- a/app/figments/models.py +++ b/app/figments/models.py @@ -7,8 +7,7 @@ from django.contrib.syndication.views import Feed from django.db.models.signals import post_save from django.dispatch import receiver -# http://freewisdom.org/projects/python-markdown/ -import markdown +from utils.widgets import markdown_to_html from .ebook import generate_epub_file @@ -77,7 +76,7 @@ class Figment(models.Model): def save(self, *args, **kwargs): if not self.id and not self.pub_date: self.pub_date = datetime.datetime.now() - self.body_html = markdown.markdown(self.body_markdown, extensions=['extra'], safe_mode=False) + self.body_html = markdown_to_html(self.body_markdown) super(Figment, self).save() diff --git a/app/guide/models.py b/app/guide/models.py index 4108e27..7f0d501 100644 --- a/app/guide/models.py +++ b/app/guide/models.py @@ -5,13 +5,13 @@ from django.contrib.sitemaps import Sitemap from django.contrib.syndication.views import Feed from PIL import Image - -import markdown from taggit.managers import TaggableManager from locations.models import Location from jrnl.models import Entry from photos.models import PhotoGallery +from utils.widgets import markdown_to_html + def get_upload_path(self, filename): return "images/guide-images/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename) @@ -27,7 +27,7 @@ def image_url_replace(str): def markdown_processor(md): - return markdown.markdown(md, ['footnotes'], safe_mode=False) + return markdown_to_html(md) class Guide(models.Model): @@ -90,17 +90,14 @@ class Guide(models.Model): return '%sguide-images/%s/%s' % (settings.IMAGES_URL, image_dir, img) def save(self): - #get image dimensions if self.image: img = Image.open(self.image) self.image_width, self.image_height = img.size - #same for thumb img = Image.open(self.thumbnail) self.thumb_width, self.thumb_height = img.size md = image_url_replace(self.body_markdown) - #run markdown - self.body_html = markdown_processor(md) - self.dek = markdown.markdown(self.dek, safe_mode=False) + self.body_html = markdown_to_html(md) + self.dek = markdown_to_html(self.dek) super(Guide, self).save() diff --git a/app/links/models.py b/app/links/models.py index 2c3480f..d2b6ff7 100644 --- a/app/links/models.py +++ b/app/links/models.py @@ -6,15 +6,7 @@ from django.contrib.sitemaps import Sitemap from django.contrib.syndication.views import Feed from taggit.managers import TaggableManager -import markdown - -RATINGS = ( - ('1', "1 Star"), - ('2', "2 Stars"), - ('3', "3 Stars"), - ('4', "4 Stars"), - ('5', "5 Stars"), -) +from utils.widgets import markdown_to_html class Link(models.Model): @@ -39,7 +31,7 @@ class Link(models.Model): return reverse("links:detail", kwargs={"slug": self.pk}) def render_description(self): - return markdown.markdown(self.description, extensions=['extra'], safe_mode=False) + return markdown_to_html(self.description) def get_previous_published(self): return self.get_previous_by_pub_date(status__exact=1) diff --git a/app/notes/models.py b/app/notes/models.py index 25062d0..6d5e805 100644 --- a/app/notes/models.py +++ b/app/notes/models.py @@ -1,11 +1,3 @@ -''' -TODO: -2) test urlize with markdown links -3) parse out markdown wrapped links for twitter -4) CSS -6) Write JavaScript to automatically place map on current location -''' - import json import datetime from django.contrib.gis.db import models diff --git a/app/pages/models.py b/app/pages/models.py index 0062bd9..ed7b94e 100644 --- a/app/pages/models.py +++ b/app/pages/models.py @@ -1,6 +1,8 @@ from django.db import models from django.contrib.sitemaps import Sitemap +from utils.widgets import markdown_to_html + class Page(models.Model): title = models.CharField(max_length=200) @@ -18,7 +20,7 @@ class Page(models.Model): def save(self): # run markdown - self.body_html = markdown_processor(self.body_markdown) + self.body_html = markdown_to_html(self.body_markdown) super(Page, self).save() diff --git a/app/projects/models/base.py b/app/projects/models/base.py index f0cd6d0..44c413e 100644 --- a/app/projects/models/base.py +++ b/app/projects/models/base.py @@ -2,18 +2,14 @@ import datetime from django.contrib.gis.db import models from django.contrib.sitemaps import Sitemap from django.conf import settings -import markdown + +from utils.widgets import markdown_to_html def get_upload_path(self, filename): return "images/project-thumbs/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename) -def markdown_processor(md): - html = markdown.markdown(md, safe_mode=False).split('<break>') - return html - - class Project(models.Model): title = models.CharField(max_length=200) subtitle = models.CharField(max_length=200, null=True, blank=True) diff --git a/app/projects/models/code.py b/app/projects/models/code.py deleted file mode 100644 index 495fc2f..0000000 --- a/app/projects/models/code.py +++ /dev/null @@ -1,90 +0,0 @@ -import datetime -from django.db import models - -import markdown -PUB_STATUS = ( - (0, 'Draft'), - (1, 'Published'), - ) -def markdown_processor(md): - return markdown.markdown(md, ['footnotes'],safe_mode = False) - - -class Code(models.Model): - name = models.CharField(max_length=254) - slug = models.SlugField() - date_created = models.DateField('Date Created') - status = models.IntegerField(choices=PUB_STATUS, default=0) - body_html = models.TextField(blank=True) - - class Meta: - verbose_name_plural = "Code" - app_label = 'projects' - ordering = ('-date_created',) - # Returns the string representation of the model. - def __unicode__(self): - return self.slug - -class CodeBlogEntry(models.Model): - title = models.CharField(max_length=254) - slug = models.SlugField() - body_markdown = models.TextField() - body_html = models.TextField(blank=True) - pub_date = models.DateTimeField('Date published', blank=True) - status = models.IntegerField(choices=PUB_STATUS, default=0) - enable_comments = models.BooleanField(default=True) - - class Meta: - verbose_name_plural = "Code Blog" - app_label = 'projects' - ordering = ('-pub_date',) - - # Returns the string representation of the model. - def __unicode__(self): - return self.slug - - def get_absolute_url(self): - return "/projects/code/%s/%s/" % (self.pub_date.strftime("%Y/%b/%d").lower(), self.slug) - - @property - def get_previous_published(self): - return self.get_previous_by_pub_date(status__exact=1) - - @property - def get_next_published(self): - return self.get_next_by_pub_date(status__exact=1) - - - def comment_period_open(self): - return self.enable_comments and datetime.datetime.today() - datetime.timedelta(30) <= self.pub_date - - def save(self): - self.body_html = markdown_processor(self.body_markdown) - if not self.id and self.pub_date == None: - self.pub_date = datetime.datetime.now() - super(CodeBlogEntry, self).save() - - - -DEMO_TEMPLATES = ( - (0, 'Blank'), - (1, 'Basic_light'), - ) - - -class CodeBlogDemo(models.Model): - title = models.CharField(max_length=254) - slug = models.SlugField() - body = models.TextField(blank=True,null=True) - head = models.TextField(blank=True,null=True) - template= models.IntegerField(choices=DEMO_TEMPLATES, default=0) - pub_date = models.DateTimeField('Date published',blank=True) - class Meta: - verbose_name_plural = "Demos" - app_label = 'projects' - ordering = ('-pub_date',) - - def save(self): - if not self.id: - self.pub_date = datetime.datetime.now() - super(CodeBlogDemo, self).save() diff --git a/app/resume/models.py b/app/resume/models.py index aec1a2e..a8c9809 100644 --- a/app/resume/models.py +++ b/app/resume/models.py @@ -1,9 +1,7 @@ from django.db import models from django.core.urlresolvers import reverse -# http://freewisdom.org/projects/python-markdown/ -import markdown - +from utils.widgets import markdown_to_html class Publisher(models.Model): name = models.CharField(max_length=200) @@ -37,5 +35,5 @@ class PubItem(models.Model): def save(self, *args, **kwargs): if self.body_markdown: - self.body_html = markdown.markdown(self.body_markdown, extensions=['extra'], safe_mode=False) + self.body_html = markdown_to_html(self.body_markdown) super(PubItem, self).save() diff --git a/app/src/models.py b/app/src/models.py index 10df6b2..2b36fab 100644 --- a/app/src/models.py +++ b/app/src/models.py @@ -6,6 +6,8 @@ import markdown import datetime from itertools import chain +from utils.widgets import markdown_to_html + class Topic(models.Model): name = models.CharField(max_length=60) @@ -71,12 +73,7 @@ class Entry(models.Model): def save(self): md = image_url_replace(self.body_markdown) - self.body_html = markdown.markdown(md, extensions=[ - 'markdown.extensions.codehilite(css_class=highlight,linenums=False)', - 'markdown.extensions.fenced_code', - 'markdown.extensions.attr_list', - 'extra' - ], safe_mode=False) + self.body_html = markdown_to_html(md) super(Entry, self).save() @@ -129,15 +126,33 @@ class Book(models.Model): def save(self): md = image_url_replace(self.body_markdown) - self.body_html = markdown.markdown(md, extensions=[ - 'markdown.extensions.codehilite(css_class=highlight,linenums=False)', - 'markdown.extensions.fenced_code', - 'markdown.extensions.attr_list', - 'extra' - ], safe_mode=False) + self.body_html = markdown_to_html(md) super(Book, self).save() +'''class SrcDemo(models.Model): + title = models.CharField(max_length=254) + slug = models.SlugField() + body = models.TextField(blank=True, null=True) + head = models.TextField(blank=True, null=True) + DEMO_TEMPLATES = ( + (0, 'Blank'), + (1, 'Basic_light'), + ) + template = models.IntegerField(choices=DEMO_TEMPLATES, default=0) + pub_date = models.DateTimeField('Date published', blank=True) + + class Meta: + verbose_name_plural = "Demos" + app_label = 'projects' + ordering = ('-pub_date',) + + def save(self): + if not self.id: + self.pub_date = datetime.datetime.now() + super(SrcDemo, self).save() +''' + class SrcSitemap(Sitemap): changefreq = "never" priority = 0.7 diff --git a/app/utils/widgets.py b/app/utils/widgets.py index 05443bb..90a0505 100644 --- a/app/utils/widgets.py +++ b/app/utils/widgets.py @@ -6,16 +6,23 @@ from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ from django.conf import settings import markdown -from mdx_attr_list.mdx_attr_list import AttrListExtension -def markdown_processor(txt): + +def markdown_to_html(txt): md = markdown.Markdown( - extensions=[AttrListExtension(),'footnotes',], + extensions=[ + 'markdown.extensions.fenced_code', + 'markdown.extensions.codehilite(css_class=highlight,linenums=False)', + 'markdown.extensions.attr_list', + 'footnotes', + 'extra' + ], output_format='html5', safe_mode=False ) return md.convert(txt) + class TagListFilter(admin.SimpleListFilter): # Human-readable title which will be displayed in the # right admin sidebar just above the filter options. |