Permalink
Browse files

markdown and syntax highliting initial implementation

  • Loading branch information...
1 parent ceb9f0f commit bd7812c2521dd65edb8f20e8251d4f9014662e23 @hypertexthero committed May 17, 2011
Showing with 116 additions and 42 deletions.
  1. +4 −1 REQUIREMENTS.txt
  2. +10 −0 admin.py
  3. +62 −0 static/css/code.css
  4. +2 −1 static/css/mysite.css
  5. +30 −36 templates/base.html
  6. +8 −4 templates/flatpages/default.html
View
@@ -1,2 +1,5 @@
Django==1.3
-wsgiref==0.1.2
+wsgiref==0.1.2
+Markdown==2.0.3
+Pygments==1.4
+ElementTree==1.2.7
View
@@ -0,0 +1,10 @@
+# TODO: http://stackoverflow.com/questions/1021487/add-functionality-to-django-flatpages-without-changing-the-original-django-app
+
+# from django.contrib import admin
+# from django.contrib.flatpages.admin import FlatpageForm, FlatPageAdmin
+# from django.contrib.flatpages.models import FlatPage
+#
+# class FlatPageAdmin(admin.ModelAdmin):
+# content = models.TextField(_('content'), blank=True, help_text=_("<a href="http://daringfireball.net/projects/markdown/syntax" onclick="window.open(this.href, this.target); return false;">Markdown</a> syntax."))
+# pass
+# admin.site.register(FlatPage, FlatPageAdmin)
View
@@ -0,0 +1,62 @@
+.codehilite .hll { background-color: #ffffcc }
+.codehilite { background: #f8f8f8; }
+.codehilite .c { color: #408080; font-style: italic } /* Comment */
+.codehilite .err { border: 1px solid #FF0000 } /* Error */
+.codehilite .k { color: #008000; font-weight: bold } /* Keyword */
+.codehilite .o { color: #666666 } /* Operator */
+.codehilite .cm { color: #408080; font-style: italic } /* Comment.Multiline */
+.codehilite .cp { color: #BC7A00 } /* Comment.Preproc */
+.codehilite .c1 { color: #408080; font-style: italic } /* Comment.Single */
+.codehilite .cs { color: #408080; font-style: italic } /* Comment.Special */
+.codehilite .gd { color: #A00000 } /* Generic.Deleted */
+.codehilite .ge { font-style: italic } /* Generic.Emph */
+.codehilite .gr { color: #FF0000 } /* Generic.Error */
+.codehilite .gh { color: #000080; font-weight: bold } /* Generic.Heading */
+.codehilite .gi { color: #00A000 } /* Generic.Inserted */
+.codehilite .go { color: #808080 } /* Generic.Output */
+.codehilite .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
+.codehilite .gs { font-weight: bold } /* Generic.Strong */
+.codehilite .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+.codehilite .gt { color: #0040D0 } /* Generic.Traceback */
+.codehilite .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
+.codehilite .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
+.codehilite .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
+.codehilite .kp { color: #008000 } /* Keyword.Pseudo */
+.codehilite .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
+.codehilite .kt { color: #B00040 } /* Keyword.Type */
+.codehilite .m { color: #666666 } /* Literal.Number */
+.codehilite .s { color: #BA2121 } /* Literal.String */
+.codehilite .na { color: #7D9029 } /* Name.Attribute */
+.codehilite .nb { color: #008000 } /* Name.Builtin */
+.codehilite .nc { color: #0000FF; font-weight: bold } /* Name.Class */
+.codehilite .no { color: #880000 } /* Name.Constant */
+.codehilite .nd { color: #AA22FF } /* Name.Decorator */
+.codehilite .ni { color: #999999; font-weight: bold } /* Name.Entity */
+.codehilite .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
+.codehilite .nf { color: #0000FF } /* Name.Function */
+.codehilite .nl { color: #A0A000 } /* Name.Label */
+.codehilite .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
+.codehilite .nt { color: #008000; font-weight: bold } /* Name.Tag */
+.codehilite .nv { color: #19177C } /* Name.Variable */
+.codehilite .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
+.codehilite .w { color: #bbbbbb } /* Text.Whitespace */
+.codehilite .mf { color: #666666 } /* Literal.Number.Float */
+.codehilite .mh { color: #666666 } /* Literal.Number.Hex */
+.codehilite .mi { color: #666666 } /* Literal.Number.Integer */
+.codehilite .mo { color: #666666 } /* Literal.Number.Oct */
+.codehilite .sb { color: #BA2121 } /* Literal.String.Backtick */
+.codehilite .sc { color: #BA2121 } /* Literal.String.Char */
+.codehilite .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
+.codehilite .s2 { color: #BA2121 } /* Literal.String.Double */
+.codehilite .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
+.codehilite .sh { color: #BA2121 } /* Literal.String.Heredoc */
+.codehilite .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
+.codehilite .sx { color: #008000 } /* Literal.String.Other */
+.codehilite .sr { color: #BB6688 } /* Literal.String.Regex */
+.codehilite .s1 { color: #BA2121 } /* Literal.String.Single */
+.codehilite .ss { color: #19177C } /* Literal.String.Symbol */
+.codehilite .bp { color: #008000 } /* Name.Builtin.Pseudo */
+.codehilite .vc { color: #19177C } /* Name.Variable.Class */
+.codehilite .vg { color: #19177C } /* Name.Variable.Global */
+.codehilite .vi { color: #19177C } /* Name.Variable.Instance */
+.codehilite .il { color: #666666 } /* Literal.Number.Integer.Long */
View
@@ -9,4 +9,5 @@ p#logo {font-weight:bold;}
p.breadcrumbs {}
p#footer {font-size:0.9em; border-top:1px solid #eee; padding-top:1em; color:#999;}
p#footer a {color:#999;}
-.quiet {color:#999;}
+.quiet {color:#999;}
+pre {border:1px solid #ccc; padding:1em;}
View
@@ -1,44 +1,38 @@
<html>
<head>
- <title>{% block headtitle %}{% endblock %}My Site</title>
-
- <style type="text/css" media="screen">
- body {color:#000; background:#fff; padding:2em; margin:0;}
- p#logo {font-weight:bold;}
- p.breadcrumbs {}
- p#footer {font-size:0.9em; border-top:1px solid #eee; padding-top:1em; color:#999;}
- p#footer a {color:#999;}
- .quiet {color:#999;}
- </style>
-
- <link rel="stylesheet" href="{{ STATIC_URL }}css/mysite.css" type="text/css" media="screen" title="default" charset="utf-8" />
- <link rel="Shortcut Icon" href="{{ STATIC_URL }}favicon.ico" type="image/x-icon" />
+ <title>{% block headtitle %}{% endblock %}My Site</title>
+
+ <link rel="stylesheet" href="{{ STATIC_URL }}css/mysite.css" type="text/css" media="screen" title="default" charset="utf-8" />
+ <link rel="stylesheet" href="{{ STATIC_URL }}css/code.css" type="text/css" media="screen" charset="utf-8" />
+ <link rel="Shortcut Icon" href="{{ STATIC_URL }}favicon.ico" type="image/x-icon" />
</head>
<body>
-
- <p class="breadcrumbs">
- <strong><a href="/">My Site</a></strong> {% block breadcrumbs %}{% endblock %}
- </p>
-
- {% block content %}
- <h4>Flatpages</h4>
- {# Loading flatpages for displaying a flatpage list http://docs.djangoproject.com/en/dev/topics/templates/#loading-custom-template-libraries #}
- {% load flatpages %}
- {% get_flatpages as flatpages %}
- <ul>
- {% for page in flatpages %}
- <li><a href="{{ page.url }}">{{ page.title }}</a></li>
- {% endfor %}
- </ul>
- {% endblock %}
-
- {% block footer %}
- <p id="footer">
- This has been <a href="http://hypertexthero.com" title="Hypertexthero.com">Simon Griffee</a>, experimenting with Django.<br />
- It is currently {% now "H:i T" %} on the {% now "jS" %} of {% now "F Y" %}.
- </p>
- {% endblock %}
+
+ <p class="breadcrumbs">
+ <strong><a href="/">My Site</a></strong> {% block breadcrumbs %}{% endblock %}
+ </p>
+
+ {% block content %}
+
+ <h4>Flatpages</h4>
+
+ {# Loading flatpages for displaying a flatpage list http://docs.djangoproject.com/en/dev/topics/templates/#loading-custom-template-libraries #}
+ {% load flatpages %}
+ {% get_flatpages as flatpages %}
+ <ul>
+ {% for page in flatpages %}
+ <li><a href="{{ page.url }}">{{ page.title }}</a></li>
+ {% endfor %}
+ </ul>
+ {% endblock %}
+
+ {% block footer %}
+ <p id="footer">
+ This has been <a href="http://hypertexthero.com" title="Hypertexthero.com">Simon Griffee</a>, experimenting with Django.<br />
+ It is currently {% now "H:i T" %} on the {% now "jS" %} of {% now "F Y" %}.
+ </p>
+ {% endblock %}
</body>
</html>
@@ -1,12 +1,16 @@
{% extends "base.html" %}
{% block headtitle %}
-{{ flatpage.title }} -
+ {{ flatpage.title }} -
{% endblock %}
-{% block breadcrumbs %} / {{ flatpage.title }}{% endblock %}
+{% block breadcrumbs %}
+ / {{ flatpage.title }}
+{% endblock %}
{% block content %}
-<h1>{{ flatpage.title }}</h1>
-{{ flatpage.content }}
+ <h1>{{ flatpage.title }}</h1>
+ <!-- http://programanddesign.com/uncategorized/django-flatpages-markdown-and-syntax-highlighting/ -->
+ {% load markup %}
+ {{ flatpage.content|markdown:"safe,codehilite" }}
{% endblock %}

0 comments on commit bd7812c

Please sign in to comment.