]> git.0d.be Git - panikweb.git/commitdiff
bonnes-ondes: switch importer to textile for formatted texts
authorFrédéric Péters <fpeters@0d.be>
Sat, 21 Jul 2018 14:38:26 +0000 (16:38 +0200)
committerFrédéric Péters <fpeters@0d.be>
Sat, 21 Jul 2018 14:38:26 +0000 (16:38 +0200)
panikweb/archives/management/commands/import_bonnes_ondes.py

index 48571144f8b859384f94d86d70a31b4463e5613e..2ed93ebb07216b1115bd6e9f9e21880f2091588e 100644 (file)
@@ -2,7 +2,7 @@
 
 import os
 import yaml
-import markdown
+import textile
 from pytz import timezone
 
 from django.core.files import File
@@ -20,8 +20,8 @@ def construct_ruby_sym(loader, node):
 yaml.add_multi_constructor(u"!ruby/object:", construct_ruby_object)
 yaml.add_constructor(u"!ruby/sym", construct_ruby_sym)
 
-def get_markdown_as_html(text):
-    return markdown.markdown(text)
+def get_as_html(text):
+    return textile.textile(text)
 
 class Command(BaseCommand):
     def add_arguments(self, parser):
@@ -38,7 +38,7 @@ class Command(BaseCommand):
                 })
         show = yaml.load(open(os.path.join(dirname, 'show.yaml')))
         emission.title = show['attributes']['name']
-        emission.text = get_markdown_as_html(show['attributes']['description'])
+        emission.text = get_as_html(show['attributes']['description'])
         emission.archived = True
         emission.save()
 
@@ -59,7 +59,7 @@ class Command(BaseCommand):
             episode.diffusions().delete()
             broadcasted_at = utc.localize(episode_data['attributes']['broadcasted_at']).astimezone(europe_brussels)
             Diffusion(episode=episode, datetime=make_naive(broadcasted_at)).save()
-            episode.text = get_markdown_as_html(episode_data['attributes']['description'])
+            episode.text = get_as_html(episode_data['attributes']['description'])
             if not episode.image and episode_data['attributes'].get('image_id'):
                 episode.image = File(open(os.path.join(dirname, 'images', images[episode_data['attributes']['image_id']])))
             episode.save()