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