# HG changeset patch # User neko259 # Date 2013-04-15 19:59:38 # Node ID e544cbe231999ee3919d1912bef2f6246aa49219 # Parent 3006249c01a6100ac8fd72a776d1848cd9e71648 Added new markdown field. Added gets algorithm with regexes. diff --git a/boards/models.py b/boards/models.py --- a/boards/models.py +++ b/boards/models.py @@ -5,6 +5,7 @@ from django.utils import timezone import time from neboard import settings +from markupfield.fields import MarkupField import thumbs @@ -152,7 +153,7 @@ class Post(models.Model): title = models.CharField(max_length=50) pub_time = models.DateTimeField() - text = models.TextField() + text = MarkupField(default_markup_type='markdown', escape_html=True) image = thumbs.ImageWithThumbsField(upload_to=update_image_filename, blank=True, sizes=((200, 150),)) poster_ip = models.IPAddressField() @@ -189,17 +190,14 @@ class Post(models.Model): def is_get(self): """If the post has pretty id (1, 1000, 77777), than it is called GET""" - # TODO Make a better algorithm for describing gets - return self.id == 1 or self.id % 10 == 0 + first = self.id == 1 - def get_parsed_text(self): - text = self.text + # TODO Compile regexes - # TODO Implement parsing - # Make //text colored - # Make >>12 links to posts - - return text + id_str = str(self.id) + pretty = re.match(r'\d0+', id_str) + same_digits = re.match(r'^(.)\1{1,}$', id_str) + return first or pretty or same_digits class Admin(models.Model): diff --git a/boards/static/css/md/base_page.css b/boards/static/css/md/base_page.css --- a/boards/static/css/md/base_page.css +++ b/boards/static/css/md/base_page.css @@ -25,11 +25,6 @@ html { color: #ffffff; } -.block { - display: inline-block; - vertical-align: top; -} - .tag { color: #b4cfec; } @@ -47,6 +42,7 @@ html { margin: 5px; padding: 10px; border-radius: 5px; + clear: left; } .metadata { @@ -54,7 +50,7 @@ html { margin-top: 10px; border: solid 1px #666; font-size: 0.9em; - color: #ddd + color: #ddd; } #navigation_panel { @@ -81,7 +77,7 @@ html { padding-right: 0; } -#navigation_panel::after { +#navigation_panel::after, .post::after { clear: both; content: "."; display: block; @@ -114,6 +110,7 @@ p { .form-label { padding: .25em 1ex .25em 0; + vertical-align: top; } .form-input { diff --git a/neboard/settings.py b/neboard/settings.py --- a/neboard/settings.py +++ b/neboard/settings.py @@ -134,6 +134,7 @@ INSTALLED_APPS = ( # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', 'django.contrib.markup', + 'django_cleanup', 'boards', ) diff --git a/templates/posting_general.html b/templates/posting_general.html --- a/templates/posting_general.html +++ b/templates/posting_general.html @@ -13,19 +13,21 @@ {% for thread in threads %}
{% if thread.image %} -
+ {% endif %} -
+
{{ thread.title }} (#{{ thread.id }}) [{{ thread.pub_time }}] [{% trans "View" %}] - {{ thread.get_parsed_text|markdown:"safe"|truncatechars:300 }} + {% autoescape off %} + {{ thread.text.rendered|truncatechars:300 }} + {% endautoescape %}
{% if post.tags.all %}