Commit 93159b62 authored by Sli's avatar Sli

Ajout de template de base et ajout d'une mini nav-bar

parent 6ad4a5c9
<!DOCTYPE html>
{% extends "BaseBlog.html" %}
{% load markdown_deux_tags %}
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
{% block body %}
<h1>{{article.title}}</h1>
{% markdown %}
{{article.content}}
{% endmarkdown %}
{{article.content|markdown}}
</body>
</html>
\ No newline at end of file
{% endblock %}
\ No newline at end of file
<!DOCTYPE html>
{% extends "BaseBlog.html" %}
{% load markdown_deux_tags %}
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
{% block body %}
{% for article in articles %}
<a href="{{article.get_absolute_url}}">
<h1>{{article.title|title}}</h1>
</a>
{% markdown %}
{{article.content}}
{% endmarkdown %}
{{article.content|markdown}}
{% endfor %}
</body>
</html>
\ No newline at end of file
{% endblock %}
\ No newline at end of file
<p>
<a href="{{nav.path}}"> Home</a>
{% for page in nav.pages %}
<a href="{{page.get_absolute_url}}">{{page.title}}</a>
{% endfor %}
</p>
<!DOCTYPE html>
{% extends "BaseBlog.html" %}
{% load markdown_deux_tags %}
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
{% block body %}
<h1>{{content.title}}</h1>
{% markdown %}
{{content.content}}
{% endmarkdown %}
{{content.content|markdown}}
</body>
</html>
\ No newline at end of file
{% endblock %}
\ No newline at end of file
......@@ -2,7 +2,7 @@
# @Author: klmp200
# @Date: 2016-06-04 23:24:06
# @Last Modified by: klmp200
# @Last Modified time: 2016-06-06 16:33:05
# @Last Modified time: 2016-06-06 23:23:21
from django.conf.urls import patterns, url
......@@ -12,4 +12,4 @@ urlpatterns = patterns('blog.views',
url(r'^article/(?P<slug>.+)$', 'article', name='article'),
url(r'^p/(?P<slug>.+)$', 'page', name='page'),
)
\ No newline at end of file
)
#-*- coding: utf-8 -*-
from django.shortcuts import render, get_object_or_404
from django.core.urlresolvers import reverse
from blog.models import Article, Page
def blog(request):
articles = Article.objects.exclude(published=False).order_by('-date')
return render(request, 'blog/blog.html', {'articles': articles})
return render(request, 'blog/blog.html', {'articles': articles, 'nav': get_nav()})
def article(request, slug):
article = get_object_or_404(Article, slug=slug, published=True)
return render(request, 'blog/article.html', {'article': article})
return render(request, 'blog/article.html', {'article': article, 'nav': get_nav()})
def page(request, slug):
content = get_object_or_404(Page, slug, published=True)
content = get_object_or_404(Page, slug=slug, published=True)
return render(request, 'blog/page.html', {'content': content})
return render(request, 'blog/page.html', {'content': content, 'nav': get_nav()})
def get_nav():
nav = {
'pages': Page.objects.exclude(published=False).order_by('order'),
'path': reverse('blog')
}
return nav
......@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os
import re
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
......@@ -39,6 +40,8 @@ INSTALLED_APPS = [
'django.contrib.staticfiles',
'blog',
'markdownx',
'markdown_deux',
'ordered_model',
]
MIDDLEWARE_CLASSES = [
......@@ -57,7 +60,9 @@ ROOT_URLCONF = 'gala.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [
os.path.join(BASE_DIR, 'templates'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
......@@ -121,4 +126,73 @@ USE_TZ = True
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = 'absolute-path-to/static'
\ No newline at end of file
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
from markdown_deux.conf.settings import MARKDOWN_DEUX_DEFAULT_STYLE
MARKDOWN_DEUX_STYLES = {
"default": MARKDOWN_DEUX_DEFAULT_STYLE,
"trusted": {
"extras": {
"code-friendly": None,
},
# Allow raw HTML (WARNING: don't use this for user-generated
# Markdown for your site!).
"safe_mode": False,
},
# Here is what http://code.activestate.com/recipes/ currently uses.
"recipe": {
"extras": {
"code-friendly": None,
},
"safe_mode": "escape",
"link_patterns": [
# Transform "Recipe 123" in a link.
(re.compile(r"recipe\s+#?(\d+)\b", re.I),
r"http://code.activestate.com/recipes/\1/"),
],
"extras": {
"code-friendly": None,
"pyshell": None,
"demote-headers": 3,
"link-patterns": None,
# `class` attribute put on `pre` tags to enable using
# <http://code.google.com/p/google-code-prettify/> for syntax
# highlighting.
"html-classes": {"pre": "prettyprint"},
"cuddled-lists": None,
"footnotes": None,
"header-ids": None,
},
"safe_mode": "escape",
}
}
# Markdownify
MARKDOWNX_MARKDOWNIFY_FUNCTION = 'markdownx.utils.markdownify' # Default function that compiles markdown using defined extensions. Using custom function can allow you to pre-process or post-process markdown text. See below for more info.
# Markdown extensions
MARKDOWNX_MARKDOWN_EXTENSIONS = [
'markdown.extensions.extra',
'markdown.extensions.nl2br',
'markdown.extensions.smarty',
]
MARKDOWNX_MARKDOWN_EXTENSION_CONFIGS = {} # Configuration object for used markdown extensions
# Markdown urls
MARKDOWNX_URLS_PATH = '/markdownx/markdownify/' # URL that returns compiled markdown text.
MARKDOWNX_UPLOAD_URLS_PATH = '/markdownx/upload/' # URL that accepts file uploads, returns markdown notation of the image.
# Media path
MARKDOWNX_MEDIA_PATH = 'markdownx/' # Path, where images will be stored in MEDIA_ROOT folder
# Image
MARKDOWNX_UPLOAD_MAX_SIZE = 52428800 # 50MB - maximum file size
MARKDOWNX_UPLOAD_CONTENT_TYPES = ['image/jpeg', 'image/png'] # Acceptable file content types
MARKDOWNX_IMAGE_MAX_SIZE = {'size': (500, 500), 'quality': 90,} # Different options describing final image processing: size, compression etc. See below for more info.
# Editor
MARKDOWNX_EDITOR_RESIZABLE = True # Update editor's height to inner content height while typing
\ No newline at end of file
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Gala 2016</title>
</head>
<body>
{% include "blog/nav.html" %}
{% block body %}
{% endblock %}
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment