##// END OF EJS Templates
Added new markdown field. Added gets algorithm with regexes.
neko259 -
r39:e544cbe2 default
parent child Browse files
Show More
@@ -5,6 +5,7 b' from django.utils import timezone'
5 5 import time
6 6
7 7 from neboard import settings
8 from markupfield.fields import MarkupField
8 9
9 10 import thumbs
10 11
@@ -152,7 +153,7 b' class Post(models.Model):'
152 153
153 154 title = models.CharField(max_length=50)
154 155 pub_time = models.DateTimeField()
155 text = models.TextField()
156 text = MarkupField(default_markup_type='markdown', escape_html=True)
156 157 image = thumbs.ImageWithThumbsField(upload_to=update_image_filename,
157 158 blank=True, sizes=((200, 150),))
158 159 poster_ip = models.IPAddressField()
@@ -189,17 +190,14 b' class Post(models.Model):'
189 190 def is_get(self):
190 191 """If the post has pretty id (1, 1000, 77777), than it is called GET"""
191 192
192 # TODO Make a better algorithm for describing gets
193 return self.id == 1 or self.id % 10 == 0
193 first = self.id == 1
194 194
195 def get_parsed_text(self):
196 text = self.text
195 # TODO Compile regexes
197 196
198 # TODO Implement parsing
199 # Make //text colored
200 # Make >>12 links to posts
201
202 return text
197 id_str = str(self.id)
198 pretty = re.match(r'\d0+', id_str)
199 same_digits = re.match(r'^(.)\1{1,}$', id_str)
200 return first or pretty or same_digits
203 201
204 202
205 203 class Admin(models.Model):
@@ -25,11 +25,6 b' html {'
25 25 color: #ffffff;
26 26 }
27 27
28 .block {
29 display: inline-block;
30 vertical-align: top;
31 }
32
33 28 .tag {
34 29 color: #b4cfec;
35 30 }
@@ -47,6 +42,7 b' html {'
47 42 margin: 5px;
48 43 padding: 10px;
49 44 border-radius: 5px;
45 clear: left;
50 46 }
51 47
52 48 .metadata {
@@ -54,7 +50,7 b' html {'
54 50 margin-top: 10px;
55 51 border: solid 1px #666;
56 52 font-size: 0.9em;
57 color: #ddd
53 color: #ddd;
58 54 }
59 55
60 56 #navigation_panel {
@@ -81,7 +77,7 b' html {'
81 77 padding-right: 0;
82 78 }
83 79
84 #navigation_panel::after {
80 #navigation_panel::after, .post::after {
85 81 clear: both;
86 82 content: ".";
87 83 display: block;
@@ -114,6 +110,7 b' p {'
114 110
115 111 .form-label {
116 112 padding: .25em 1ex .25em 0;
113 vertical-align: top;
117 114 }
118 115
119 116 .form-input {
@@ -134,6 +134,7 b' INSTALLED_APPS = ('
134 134 # Uncomment the next line to enable admin documentation:
135 135 # 'django.contrib.admindocs',
136 136 'django.contrib.markup',
137 'django_cleanup',
137 138 'boards',
138 139 )
139 140
@@ -13,19 +13,21 b''
13 13 {% for thread in threads %}
14 14 <div class="post">
15 15 {% if thread.image %}
16 <div class="block">
16 <div class="image">
17 17 <a href="{{ thread.image.url }}"><img
18 18 src="{{ thread.image.url_200x150 }}" />
19 19 </a>
20 20 </div>
21 21 {% endif %}
22 <div class="block">
22 <div class="message">
23 23 <span class="title">{{ thread.title }}</span>
24 24 <span class="post_id">(#{{ thread.id }})</span>
25 25 [{{ thread.pub_time }}]
26 26 [<a class="link" href="{% url 'thread' thread.id %}"
27 27 >{% trans "View" %}</a>]
28 {{ thread.get_parsed_text|markdown:"safe"|truncatechars:300 }}
28 {% autoescape off %}
29 {{ thread.text.rendered|truncatechars:300 }}
30 {% endautoescape %}
29 31 </div>
30 32 <div class="metadata">
31 33 {{ thread.get_reply_count }} {% trans 'replies' %},
@@ -25,7 +25,9 b''
25 25 <a class="post_id" href="#{{ post.id }}">
26 26 (#{{ post.id }})</a>
27 27 [{{ post.pub_time }}]
28 {{ post.get_parsed_text|markdown:"safe" }}
28 {% autoescape off %}
29 {{ post.text.rendered }}
30 {% endautoescape %}
29 31 </div>
30 32 {% if post.tags.all %}
31 33 <div class="metadata">
General Comments 0
You need to be logged in to leave comments. Login now