Commits

Morgan LEFIEUX  committed a102880

Modification du template base.html pour support coloration syntaxique

  • Participants
  • Parent commits c687d55

Comments (0)

Files changed (2)

File blog/models.py

 from django.db import models
 from django.core.files.storage import default_storage
 from django.contrib.comments.moderation import CommentModerator, moderator
+import markdown
 
 MARKDOWN_SYNTAX = 'Syntaxe <a target="_blank" href="http://daringfireball.net/projects/markdown/syntax/"'\
-                  'title="Accès à la syntaxe">markdown</a>'
+        'title="Accès à la syntaxe">markdown</a>'
 
 class Tag(models.Model):
     name = models.CharField('Nom',max_length=50)
     def __unicode__(self):
         return self.name
 
-	
+
 class Entry(models.Model):
-	title = models.CharField('Titre',max_length=200)
-	slug = models.SlugField(
-		'Référence',
-		unique_for_date='pub_date',
-		help_text='Automatiquement formé à partir du titre.',
-		max_length=60
-	)
-	summary = models.TextField('Résumé',help_text="Un seul paragraphe. N'ajoutez pas de balise &lt;p&gt;.")
-	image = models.ImageField('Image associée', upload_to='images/', blank=True, null=True)
-	remove_image = models.BooleanField("Dissocier l'image", blank=False)
-	body_markdown = models.TextField('Contenu Markdown', help_text=MARKDOWN_SYNTAX, blank=True, null=True)
-	body = models.TextField('Contenu HTML', help_text='Utilisez la syntaxe HTML.', blank=True, null=True)
-	pub_date = models.DateTimeField('Date de publication')
-	tags = models.ManyToManyField(Tag, verbose_name=u"Catégorie(s)")
-	is_public = models.BooleanField("Publier ce billet", default=False)
-	enable_comments = models.BooleanField('Autoriser les commentaires')
+    title = models.CharField('Titre',max_length=200)
+    slug = models.SlugField(
+            'Référence',
+            unique_for_date='pub_date',
+            help_text='Automatiquement formé à partir du titre.',
+            max_length=60
+            )
+    summary = models.TextField('Résumé',help_text="Un seul paragraphe. N'ajoutez pas de balise &lt;p&gt;.")
+    image = models.ImageField('Image associée', upload_to='images/', blank=True, null=True)
+    remove_image = models.BooleanField("Dissocier l'image", blank=False)
+    body_markdown = models.TextField('Contenu Markdown', help_text=MARKDOWN_SYNTAX, blank=True, null=True)
+    body = models.TextField('Contenu HTML', help_text='Utilisez la syntaxe HTML.', blank=True, null=True)
+    pub_date = models.DateTimeField('Date de publication')
+    tags = models.ManyToManyField(Tag, verbose_name=u"Catégorie(s)")
+    is_public = models.BooleanField("Publier ce billet", default=False)
+    enable_comments = models.BooleanField('Autoriser les commentaires')
 
-	class Meta:
-		ordering = ('-pub_date',)
-		get_latest_by = 'pub_date'
-		verbose_name = ('billet')
-		verbose_name_plural = ('billets')
-				
-	def __unicode__(self):
-		return self.title
-	
-	def get_absolute_url(self):
-		return "/blog/%s/%s/" % (self.pub_date.strftime("%Y/%m/%d").lower(), self.slug)
-	
-	def save(self):
-		"""Vérifications avant l'enregistrement"""
-		try:
-			old_img = Entry.objects.get(pk=self.id)
-			path = old_img.image.path
-			if old_img.image.path != self.image.path:
-				default_storage.delete(path)
-			elif self.remove_image:
-				self.image=None
-				default_storage.delete(path)
-		except:
-			pass
-		finally:
-			self.remove_image=False
-		import markdown
-		if self.body_markdown:
-			self.body = markdown.markdown(self.body_markdown, extensions=['fenced_code'], safe_mode="escape")
-        	super(Entry, self).save() # Call the "real" save() method.
+    class Meta:
+        ordering = ('-pub_date',)
+        get_latest_by = 'pub_date'
+        verbose_name = ('billet')
+        verbose_name_plural = ('billets')
+
+    def __unicode__(self):
+        return self.title
+
+    def get_absolute_url(self):
+        return "/blog/%s/%s/" % (self.pub_date.strftime("%Y/%m/%d").lower(), self.slug)
+
+    def save(self):
+        """Vérifications avant l'enregistrement"""
+        try:
+            old_img = Entry.objects.get(pk=self.id)
+            path = old_img.image.path
+            if old_img.image.path != self.image.path:
+                default_storage.delete(path)
+            elif self.remove_image:
+                self.image=None
+                default_storage.delete(path)
+        except:
+            pass
+        finally:
+            self.remove_image=False
+        if self.body_markdown: 
+            self.body = markdown.markdown(self.body_markdown, extensions=['fenced_code'], safe_mode="escape")
+        super(Entry, self).save() # Call the "real" save() method.
 
 class EntryModerator(CommentModerator):
     email_notification = True

File templates/base.html

 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
 <head>
 	<title>Gérard is a geek ! - {% block title %}{% endblock %}</title>
-	<link rel="stylesheet" href="/media/giag/css/style.css" />
+    <link rel="stylesheet" href="{{ MEDIA_URL }}css/style.css" />
+    <link rel="stylesheet" href="{{ MEDIA_URL }}css/zenburn.css" />
 	<link rel="alternate" type="application/rss+xml" title="Gérard is a geek !: Derniers billets" 
 	href="/feeds/posts" />
-	<link rel="icon" href="/media/giag/css/img/favicon.ico" type="image/x-icon" />
-	<link rel="shortcut icon" href="/media/giag/css/img/favicon.ico" type="image/x-icon" />
+	<link rel="icon" href="{{ MEDIA_URL }}css/img/favicon.ico" type="image/x-icon" />
+	<link rel="shortcut icon" href="{{ MEDIA_URL }}css/img/favicon.ico" type="image/x-icon" />
 	<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
 </head>
 <body>
 	</div>
 </div>
 
-<script src="/media/giag/scripts/base.js" type="text/javascript"></script>
-<script src="/media/giag/scripts/googleAnalytics.js" type="text/javascript"></script>
+<script src="{{ MEDIA_URL }}scripts/highlight.pack.js" type="text/javascript"></script>
+<script src="{{ MEDIA_URL }}scripts/base.js" type="text/javascript"></script>
+<script src="{{ MEDIA_URL }}scripts/googleAnalytics.js" type="text/javascript"></script>
 
 </body>
 </html>