Commits

Andrés Reyes Monge committed 4d3a3f2

- Trabajando más en los estilos del blog

Comments (0)

Files changed (9)

armonge_info/settings/settings.py

     'compressor',
     'south',
     'disqus',
+    'markitup',
 
     'tagging',
     'blog',
     ('text/less', 'lessc {infile} {outfile}'),
  )
 
-COMPRESS_ENABLED = True
+COMPRESS_ENABLED = True
+
+MARKITUP_FILTER = ('armonge_info.utils.markup_filter', {})

armonge_info/utils.py

+# -*- coding: utf-8 -*-
+from django.utils.safestring import mark_safe
+from markdown import markdown
+import re
+from urlparse import urljoin
+from BeautifulSoup import BeautifulSoup, Comment
+
+def sanitizeHtml(value, base_url=None):
+    rjs = r'[\s]*(&#x.{1,7})?'.join(list('javascript:'))
+    rvb = r'[\s]*(&#x.{1,7})?'.join(list('vbscript:'))
+    re_scripts = re.compile('(%s)|(%s)' % (rjs, rvb), re.IGNORECASE)
+    validTags = 'span p i strong b u a h1 h2 h3 blockquote br ul ol li img pre'.split()
+    validAttrs = 'href src title class'.split()
+    urlAttrs = 'href src'.split() # Attributes which should have a URL
+    soup = BeautifulSoup(value)
+    for comment in soup.findAll(text=lambda text: isinstance(text, Comment)):
+        # Get rid of comments
+        comment.extract()
+    for tag in soup.findAll(True):
+        if tag.name not in validTags:
+            tag.hidden = True
+        attrs = tag.attrs
+        tag.attrs = []
+        for attr, val in attrs:
+            if attr in validAttrs:
+                val = re_scripts.sub('', val) # Remove scripts (vbs & js)
+                if attr in urlAttrs:
+                    val = urljoin(base_url, val) # Calculate the absolute url
+                tag.attrs.append((attr, val))
+
+    return soup.renderContents().decode('utf8')
+
+def markup_filter(markup):
+    markup = sanitizeHtml(markup)
+    return mark_safe( markdown(markup))

assets/css/style.less

 @import "bootstrap/bootstrap.less";
 
+html, body{
+    height: 100%;
+}
+.wrapper{
+    min-height: 100%;
+    position:relative;
+}
+#main{
+    padding-bottom: 140px;
+}
 .post{
-    border-bottom: 1px
+    border-bottom: 1px solid #DDD;
+}
+footer{
+    width: 100%;
+    position: absolute;
+    bottom: 0;
+    height: 120px;
+}
+footer .container{
+    padding-top: 10px;
+    border-top: 1px solid #DDD;
+
 }
Added
New image

assets/js/script.js

 /* Author:
 
 */
+$(document).ready(function(){
 
-
-
-
-
+})

blog/templates/blog/post_detail.html

 {% extends 'base.html' %}
-{% load disqus_tags %}
+{% load disqus_tags markitup_tags %}
 
 {% block title %}
     {{ post }}
         <h1 class="span">{{ post }}</h1>
     </div>
     <div class="row">
-        <div class="span">{{ post.text|linebreaks }}</div>
+        <div class="span2">
+            <span class="date"><i class="icon-calendar"></i> {{ post.date_published.date }}</span> <br>
+            {% if post.tags %}
+                <span class="tags">
+
+                <i class="icon-tag"></i>
+                {% for tag in post.tags %}
+                <a href="{% url blog_post_list_by_tag tag %}">{{ tag }}</a>{% if not forloop.last %}, {% endif %}
+                {% endfor %}
+            </span> <br>
+            {% endif %}
+            <span class="comments"><i class="icon-comment"></i>
+                <a href="{{ post.get_absolute_url}}#disqus_thread" data-disqus-identifier="{{ post.id }}">Comentarios</a>
+                {% disqus_num_replies %}
+            </span> <br>
+
+        </div>
+        <div class="span10">{{ post.text|render_markup }}</div>
     </div>
     <div class="row">
-        <div class="span">
+
+        <div class="span12">
             {% set_disqus_url post.get_absolute_url %}
             {% set_disqus_title post.name %}
             {% set_disqus_identifier post.id %}
 BeautifulSoup
 django-tagging
 django-disqus
+django-markitup
+Markdown

templates/base.html

 <!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
 <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
 <head>
-  <meta charset="utf-8">
-  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-  <title>{% block title %}{% endblock %}</title>
-  <meta name="description" content="">
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <title>{% block title %}{% endblock %}</title>
+    <meta name="description" content="">
 
-  <meta name="viewport" content="width=device-width">
+    <meta name="viewport" content="width=device-width">
     {% compress css %}
-    <link rel="stylesheet" href="{{ STATIC_URL }}css/style.less" type="text/less">
+        <link rel="stylesheet" href="{{ STATIC_URL }}css/style.less" type="text/less">
     {% endcompress %}
+    <link rel="stylesheet" href="http://yandex.st/highlightjs/6.2/styles/default.min.css">
 
-  <script src="{{ STATIC_URL }}js/libs/modernizr-2.5.3.min.js"></script>
+
+    <script src="{{ STATIC_URL }}js/libs/modernizr-2.5.3.min.js"></script>
 </head>
 <body>
-  <!--[if lt IE 7]><p class=chromeframe>Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p><![endif]-->
-  <header class="container">
-      {% block header %}
-          <div class="navbar">
-            <div class="navbar-inner">
-              <div class="container">
-                  <a class="brand" href="/">
-                    El Blog de armonge
-                  </a>
-                  <ul class="nav">
-                    <li><a href="/">Blog</a></li>
-                    <li><a href="{% url blog_post_list %}">Archivo</a></li>
-                  </ul>
-              </div>
+<div class="wrapper">
+
+    <!--[if lt IE 7]><p class=chromeframe>Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p><![endif]-->
+    <header class="container">
+        {% block header %}
+            <div class="navbar">
+                <div class="navbar-inner">
+                    <div class="container">
+                        <a class="brand" href="/">
+                            El Blog de armonge
+                        </a>
+                        <ul class="nav">
+                            <li><a href="/">Blog</a></li>
+                            <li><a href="{% url blog_post_list %}">Archivo</a></li>
+                        </ul>
+                    </div>
+                </div>
             </div>
-          </div>
-      {% endblock %}
-  </header>
-  <div role="main" class="container">
-      {% block content %}{% endblock %}
-  </div>
-  <footer class="container">
-      {% block footer %}
-      
-      {% endblock %}
-  </footer>
-
-
-  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
-  <script>window.jQuery || document.write('<script src="{{ STATIC_URL }}js/libs/jquery-1.7.1.min.js"><\/script>')</script>
-
-  <script src="{{ STATIC_URL }}js/plugins.js"></script>
-  <script src="{{ STATIC_URL }}js/script.js"></script>
-
-  <script>
-    var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
-    (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
-    g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
-    s.parentNode.insertBefore(g,s)}(document,'script'));
-  </script>
+        {% endblock %}
+    </header>
+    <div role="main" id="main" class="container">
+        {% block content %}{% endblock %}
+    </div>
+    <footer>
+        <div class="container">
+            {% block footer %}
+                <div class="row">
+                    <div class="span2">
+                        <img src="{{ STATIC_URL }}img/cara.png" alt="armonge">
+                    </div>
+                    <div class="span10">
+                        &copy; {% now "Y" %} armonge.info
+                    </div>
+                </div>
+            {% endblock %}
+        </div>
+    </footer>
+
+
+    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
+    <script>window.jQuery || document.write('<script src="{{ STATIC_URL }}js/libs/jquery-1.7.1.min.js"><\/script>')</script>
+
+    <script src="{{ STATIC_URL }}js/plugins.js"></script>
+    <script src="http://yandex.st/highlightjs/6.2/highlight.min.js"></script>
+
+
+
+    <script>
+        var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
+        (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
+            g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
+            s.parentNode.insertBefore(g,s)}(document,'script'));
+    </script>
+
+</div>
 </body>
 </html>

templates/blog/post_list_with_content.html

 {% load disqus_tags %}
 {% block content %}
     {% for post in post_list %}
-        <div class="row post">
+        <div class="row">
             <div class="span2">
                 <span class="date"><i class="icon-calendar"></i> {{ post.date_published.date }}</span> <br>
                 <span class="tags">
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.