Add output language support
This commit is contained in:
parent
c5744585c7
commit
27bd360abe
|
@ -19,6 +19,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from dynastie.models import Language
|
||||||
|
|
||||||
class UserProfile(models.Model):
|
class UserProfile(models.Model):
|
||||||
# This field is required.
|
# This field is required.
|
||||||
|
@ -26,3 +27,6 @@ class UserProfile(models.Model):
|
||||||
|
|
||||||
# Other fields here
|
# Other fields here
|
||||||
editor = models.CharField(max_length=20, default="TinyMCE")
|
editor = models.CharField(max_length=20, default="TinyMCE")
|
||||||
|
|
||||||
|
default_language = models.ForeignKey(Language, on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ class PostForm(ModelForm):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(PostForm, self).__init__(*args, **kwargs)
|
super(PostForm, self).__init__(*args, **kwargs)
|
||||||
self.fields['category'].choices = [(cat.id, cat.name) for cat in Category.objects.all()]
|
self.fields['category'].choices = [(cat.id, cat.name) for cat in Category.objects.all()]
|
||||||
|
self.fields['language'].choices = [(lang.id, lang.name) for lang in Language.objects.all()]
|
||||||
|
|
||||||
class DraftForm(PostForm):
|
class DraftForm(PostForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -319,6 +319,9 @@ class Index(DynastieGenerator):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if post.language != None:
|
||||||
|
post_elem.setAttribute('lang', post.language.abbrev)
|
||||||
|
|
||||||
self.parent_posts = []
|
self.parent_posts = []
|
||||||
post_content = self._loadPostContent(post)
|
post_content = self._loadPostContent(post)
|
||||||
if not post_content: return None
|
if not post_content: return None
|
||||||
|
|
|
@ -134,7 +134,13 @@ class Post(Index):
|
||||||
new_elem = self.createMeta(dom, name, post.author.first_name + ' ' + post.author.last_name)
|
new_elem = self.createMeta(dom, name, post.author.first_name + ' ' + post.author.last_name)
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
elif name == 'lang':
|
||||||
|
meta_elem.removeChild(root)
|
||||||
|
# Add attribute lang in <html> tag
|
||||||
|
if post.language != None:
|
||||||
|
meta_elem.parentNode.setAttribute('lang', post.language.abbrev)
|
||||||
|
return None
|
||||||
|
|
||||||
if not new_elem is None:
|
if not new_elem is None:
|
||||||
root.parentNode.replaceChild(new_elem, root)
|
root.parentNode.replaceChild(new_elem, root)
|
||||||
return new_elem
|
return new_elem
|
||||||
|
|
|
@ -41,6 +41,10 @@ def slugify(name):
|
||||||
name = sub('-+', '-', name)
|
name = sub('-+', '-', name)
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
class Language(models.Model):
|
||||||
|
name = models.CharField(max_length=255, unique=True)
|
||||||
|
abbrev = models.CharField(max_length=4, unique=True)
|
||||||
|
|
||||||
class Blog(models.Model):
|
class Blog(models.Model):
|
||||||
name = models.CharField(max_length=255, unique=True)
|
name = models.CharField(max_length=255, unique=True)
|
||||||
title = models.CharField(max_length=255)
|
title = models.CharField(max_length=255)
|
||||||
|
@ -281,12 +285,13 @@ class Post(models.Model):
|
||||||
keywords = models.TextField(blank=True)
|
keywords = models.TextField(blank=True)
|
||||||
tags = models.ManyToManyField(Tag, blank=True, null=True)
|
tags = models.ManyToManyField(Tag, blank=True, null=True)
|
||||||
blog = models.ForeignKey(Blog, on_delete=models.CASCADE)
|
blog = models.ForeignKey(Blog, on_delete=models.CASCADE)
|
||||||
|
language = models.ForeignKey(Language, null=True, on_delete=models.CASCADE)
|
||||||
CONTENT_HTML = 0
|
CONTENT_HTML = 0
|
||||||
CONTENT_TEXT = 1
|
CONTENT_TEXT = 1
|
||||||
CONTENT_FORMAT = (
|
CONTENT_FORMAT = (
|
||||||
(CONTENT_HTML, 'HTML'),
|
(CONTENT_HTML, 'HTML'),
|
||||||
(CONTENT_TEXT, 'Text'))
|
(CONTENT_TEXT, 'Text'))
|
||||||
content_format = models.IntegerField(choices=CONTENT_FORMAT, default=CONTENT_HTML, blank=False, null=False)
|
content_format = models.IntegerField(choices=CONTENT_FORMAT, default=CONTENT_TEXT, blank=False, null=False)
|
||||||
post_type = models.CharField(max_length=1, default='P')
|
post_type = models.CharField(max_length=1, default='P')
|
||||||
|
|
||||||
def getPath(self):
|
def getPath(self):
|
||||||
|
@ -460,7 +465,7 @@ class Comment(models.Model):
|
||||||
|
|
||||||
def _remove_br(self):
|
def _remove_br(self):
|
||||||
self.the_comment = self.the_comment.replace('<br />', '\n')
|
self.the_comment = self.the_comment.replace('<br />', '\n')
|
||||||
|
|
||||||
class FileOutputCache(models.Model):
|
class FileOutputCache(models.Model):
|
||||||
name = models.CharField(max_length=512)
|
name = models.CharField(max_length=512)
|
||||||
hash = models.CharField(max_length=512)
|
hash = models.CharField(max_length=512)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<html xmlns:dyn="http://indefero.soutade.fr/p/dynastie" xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns:dyn="http://indefero.soutade.fr/p/dynastie" xmlns="http://www.w3.org/1999/xhtml" lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
|
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
|
||||||
<meta content="index, follow" name="robots"/>
|
<meta content="index, follow" name="robots"/>
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
<img id="hamburger_logo" alt="Menu" src="/images/hamburger.png"/>
|
<img id="hamburger_logo" alt="Menu" src="/images/hamburger.png"/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu" id="menu">
|
<div class="menu" id="menu" lang="fr">
|
||||||
<div class="menu_content">
|
<div class="menu_content">
|
||||||
<div class="menu_content_header">Recherche</div>
|
<div class="menu_content_header">Recherche</div>
|
||||||
<div class="menu_main">
|
<div class="menu_main">
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<dyn:meta name="keywords"/>
|
<dyn:meta name="keywords"/>
|
||||||
<dyn:meta name="title"/>
|
<dyn:meta name="title"/>
|
||||||
<dyn:meta name="author"/>
|
<dyn:meta name="author"/>
|
||||||
|
<dyn:meta name="lang"/>
|
||||||
<meta content="Dynastie" name="generator"/>
|
<meta content="Dynastie" name="generator"/>
|
||||||
<meta name="viewport" content="width=width, initial-scale=1"/>
|
<meta name="viewport" content="width=width, initial-scale=1"/>
|
||||||
<title>Blog de Grégory Soutadé</title>
|
<title>Blog de Grégory Soutadé</title>
|
||||||
|
@ -36,7 +37,7 @@
|
||||||
<img id="hamburger_logo" alt="Menu" src="/images/hamburger.png"/>
|
<img id="hamburger_logo" alt="Menu" src="/images/hamburger.png"/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="menu" id="menu">
|
<div class="menu" id="menu" lang="fr">
|
||||||
<div class="menu_content">
|
<div class="menu_content">
|
||||||
<div class="menu_content_header">Recherche</div>
|
<div class="menu_content_header">Recherche</div>
|
||||||
<div class="menu_main">
|
<div class="menu_main">
|
||||||
|
|
|
@ -23,16 +23,16 @@
|
||||||
<dyn:comment_content/>
|
<dyn:comment_content/>
|
||||||
<dyn:replace div_name="a" href="javascript:void(0);" onClick="javascript:display('response_dyn:comment_index');">Répondre</dyn:replace><br/>
|
<dyn:replace div_name="a" href="javascript:void(0);" onClick="javascript:display('response_dyn:comment_index');">Répondre</dyn:replace><br/>
|
||||||
<dyn:replace div_name="form" id="response_dyn:comment_index" class="response" method="POST" action="/comment/add/dyn:post_id/dyn:comment_id" onsubmit="return validateComment('response_dyn:comment_index');">
|
<dyn:replace div_name="form" id="response_dyn:comment_index" class="response" method="POST" action="/comment/add/dyn:post_id/dyn:comment_id" onsubmit="return validateComment('response_dyn:comment_index');">
|
||||||
Auteur :<br/><input type="required" name="author"/><br/><br/>
|
Auteur :<br/><input required="1" name="author"/><br/><br/>
|
||||||
e-mail* :<br/><input id="email" type="email" name="email"/><input type="email" name="mel"/><br/><br/>
|
e-mail* :<br/><input id="email" type="email" name="email"/><input type="email" name="mel"/><br/><br/>
|
||||||
Le commentaire :<br/><textarea type="required" name="the_comment" cols="80" rows="10"> </textarea><br/><br/>
|
Le commentaire :<br/><textarea required="1" name="the_comment" cols="80" rows="10"> </textarea><br/><br/>
|
||||||
<input type="submit" value="Commenter"/>
|
<input type="submit" value="Commenter"/>
|
||||||
</dyn:replace>
|
</dyn:replace>
|
||||||
</dyn:comments>
|
</dyn:comments>
|
||||||
<dyn:replace div_name="form" id="response_0" method="POST" action="/comment/add/dyn:post_id/0" onsubmit="return validateComment('response_0');">
|
<dyn:replace div_name="form" id="response_0" method="POST" action="/comment/add/dyn:post_id/0" onsubmit="return validateComment('response_0');">
|
||||||
Auteur :<br/><input type="required" name="author"/><br/><br/>
|
Auteur :<br/><input required="1" name="author"/><br/><br/>
|
||||||
e-mail* :<br/><input id="email" type="email" name="email"/><input type="email" name="mel"/><br/><br/>
|
e-mail* :<br/><input id="email" type="email" name="email"/><input type="email" name="mel"/><br/><br/>
|
||||||
Le commentaire :<br/><textarea type="required" name="the_comment" cols="80" rows="10"> </textarea><br/><br/>
|
Le commentaire :<br/><textarea required="1" name="the_comment" cols="80" rows="10"> </textarea><br/><br/>
|
||||||
<input type="submit" value="Commenter"/><br/><br/>
|
<input type="submit" value="Commenter"/><br/><br/>
|
||||||
* Seulement pour être notifié d'une réponse à cet article
|
* Seulement pour être notifié d'une réponse à cet article
|
||||||
</dyn:replace>
|
</dyn:replace>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
|
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
|
||||||
<meta content="index, follow" name="robots"/>
|
<meta content="index, follow" name="robots"/>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user