<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -30,6 +30,11 @@ from django.contrib.auth import views, authenticate
 from django.core.paginator import QuerySetPaginator
 from django.contrib.sites.models import Site
 
+from pygments import highlight
+from pygments.util import ClassNotFound
+from pygments.formatters import HtmlFormatter
+from pygments.lexers import get_lexer_for_filename
+
 CHARACTERS_TO_STRIP = re.compile(r&quot;[ \.,\!\?'\&quot;;:/\\+=#]+&quot;)
 def sluggify(str):
     return CHARACTERS_TO_STRIP.subn(u&quot;-&quot;, str.lower())[0].strip(&quot;-&quot;)
@@ -316,27 +321,27 @@ CODE_EXTS = [&quot;css&quot;, &quot;html&quot;, &quot;htm&quot;, &quot;c&quot;, &quot;o&quot;, &quot;py&quot;, &quot;lisp&quot;, &quot;js&quot;, &quot;xml&quot;,
 
 @login_required
 def display_resource(request, id):
-    def guess_type(resource):
-        path = resource.content
-        print path
-        ext = path.split(&quot;.&quot;)[-1]
-        print ext
-        if ext in IMAGE_EXTS:
-            return &quot;image&quot;
-        elif ext in ZIP_EXTS:
-            return &quot;zip&quot;
-        elif ext in CODE_EXTS:
-            return &quot;code&quot;
-        else:
-            return &quot;file&quot;
     res = Resource.objects.get(pk=id)
     file = res.content.split(&quot;/&quot;)[-1]
-    type = guess_type(res)
-    return render_to_response('lifeflow/editor/resource.html',
-                              {'object':res,
-                               'file':file,
-                              'type':type},
-                              RequestContext(request, {}))
+    opts = {'object':res,'file':file}
+    ext = opts['file'].split(&quot;.&quot;)[-1]
+    opts['type'] = 'file'
+    if ext in IMAGE_EXTS:
+        opts['type'] = &quot;image&quot;
+    elif ext in ZIP_EXTS:
+        opts['type'] = &quot;zip&quot;
+    else:
+        try:
+            lexer = get_lexer_for_filename(file)
+            f = open(res.get_content_filename(),'r')
+            data = f.read()
+            f.close()
+            opts['highlighted_code'] = highlight(data,lexer,HtmlFormatter())
+            opts['type'] = &quot;code&quot;
+        except ClassNotFound:
+            opts['type'] = &quot;file&quot;
+
+    return render_to_response('lifeflow/editor/resource.html',opts,RequestContext(request, {}))
 
 
 @login_required</diff>
      <filename>editor/views.py</filename>
    </modified>
    <modified>
      <diff>@@ -18,4 +18,7 @@
 {% endifequal %}
 
 {% ifequal type &quot;code&quot; %}
+&lt;div class=&quot;extra&quot;&gt;
+{{ highlighted_code|safe }}
+&lt;/div&gt;
 {% endifequal %}
\ No newline at end of file</diff>
      <filename>templates/lifeflow/editor/resource.html</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d89b3ee8addb7642c0df2eb8ab832e84e54725d0</id>
    </parent>
  </parents>
  <author>
    <name>Will Larson</name>
    <email>lethain@gmail.com</email>
  </author>
  <url>http://github.com/lethain/lifeflow/commit/2c1b70e757c3dcd074a66b845dd958dc11942fcc</url>
  <id>2c1b70e757c3dcd074a66b845dd958dc11942fcc</id>
  <committed-date>2008-07-09T16:01:04-07:00</committed-date>
  <authored-date>2008-07-09T16:01:04-07:00</authored-date>
  <message>Added support to file viewer in LifeFlow Editor to display syntax colored version of code resources.
Meaning, when you are browsing through your collection of uploaded files, you can now view code files with syntax coloring (along with viewing images as well).</message>
  <tree>14c388f4efaab5a94e0c7bfa136c48f5b00ac211</tree>
  <committer>
    <name>Will Larson</name>
    <email>lethain@gmail.com</email>
  </committer>
</commit>
