##// END OF EJS Templates
#12 Fixed formatting of comments and links. Added a style for target post in the white theme.
neko259 -
r62:0e0d3099 default
parent child Browse files
Show More
@@ -1,83 +1,83 b''
1 import markdown
1 import markdown
2 from markdown.inlinepatterns import Pattern
2 from markdown.inlinepatterns import Pattern
3 from markdown.util import etree
3 from markdown.util import etree
4
4
5 __author__ = 'vurdalak'
5 __author__ = 'vurdalak'
6
6
7
7
8 class AutolinkPattern(Pattern):
8 class AutolinkPattern(Pattern):
9 def handleMatch(self, m):
9 def handleMatch(self, m):
10 link_element = etree.Element('a')
10 link_element = etree.Element('a')
11 href = m.group(2)
11 href = m.group(2)
12 link_element.set('href', href)
12 link_element.set('href', href)
13 link_element.text = href
13 link_element.text = href
14
14
15 return link_element
15 return link_element
16
16
17
17
18 class QuotePattern(Pattern):
18 class QuotePattern(Pattern):
19 def handleMatch(self, m):
19 def handleMatch(self, m):
20 quote_element = etree.Element('span')
20 quote_element = etree.Element('span')
21 quote_element.set('class', 'quote')
21 quote_element.set('class', 'quote')
22 quote_element.text = m.group(3)
22 quote_element.text = m.group(3)
23
23
24 return quote_element
24 return quote_element
25
25
26
26
27 class ReflinkPattern(Pattern):
27 class ReflinkPattern(Pattern):
28 def handleMatch(self, m):
28 def handleMatch(self, m):
29 ref_element = etree.Element('a')
29 ref_element = etree.Element('a')
30 post_id = m.group(4)
30 post_id = m.group(4)
31 ref_element.set('href', '#' + str(post_id))
31 ref_element.set('href', '#' + str(post_id))
32 ref_element.text = '#' + post_id
32 ref_element.text = '#' + post_id
33
33
34 return ref_element
34 return ref_element
35
35
36
36
37 class SpoilerPattern(Pattern):
37 class SpoilerPattern(Pattern):
38 def handleMatch(self, m):
38 def handleMatch(self, m):
39 quote_element = etree.Element('span')
39 quote_element = etree.Element('span')
40 quote_element.set('class', 'spoiler')
40 quote_element.set('class', 'spoiler')
41 quote_element.text = m.group(2)
41 quote_element.text = m.group(2)
42
42
43 return quote_element
43 return quote_element
44
44
45
45
46 class CommentPattern(Pattern):
46 class CommentPattern(Pattern):
47 def handleMatch(self, m):
47 def handleMatch(self, m):
48 quote_element = etree.Element('span')
48 quote_element = etree.Element('span')
49 quote_element.set('class', 'comment')
49 quote_element.set('class', 'comment')
50 quote_element.text = '//' + m.group(3)
50 quote_element.text = '//' + m.group(3)
51
51
52 return quote_element
52 return quote_element
53
53
54
54
55 class NeboardMarkdown(markdown.Extension):
55 class NeboardMarkdown(markdown.Extension):
56 AUTOLINK_PATTERN = r'(http://\S+)'
56 AUTOLINK_PATTERN = r'(https?://\S+)'
57 QUOTE_PATTERN = r'(>){1}(.+)'
57 QUOTE_PATTERN = r'^(>){1}(.+)'
58 REFLINK_PATTERN = r'((>){2}(\d+))'
58 REFLINK_PATTERN = r'((>){2}(\d+))'
59 SPOILER_PATTERN = r'%%(.+)%%'
59 SPOILER_PATTERN = r'%%(.+)%%'
60 COMMENT_PATTERN = r'(//(.+))'
60 COMMENT_PATTERN = r'^(//(.+))'
61
61
62 def extendMarkdown(self, md, md_globals):
62 def extendMarkdown(self, md, md_globals):
63 autolink = AutolinkPattern(self.AUTOLINK_PATTERN, md)
63 autolink = AutolinkPattern(self.AUTOLINK_PATTERN, md)
64 quote = QuotePattern(self.QUOTE_PATTERN, md)
64 quote = QuotePattern(self.QUOTE_PATTERN, md)
65 reflink = ReflinkPattern(self.REFLINK_PATTERN, md)
65 reflink = ReflinkPattern(self.REFLINK_PATTERN, md)
66 spoiler = SpoilerPattern(self.SPOILER_PATTERN, md)
66 spoiler = SpoilerPattern(self.SPOILER_PATTERN, md)
67 comment = CommentPattern(self.COMMENT_PATTERN, md)
67 comment = CommentPattern(self.COMMENT_PATTERN, md)
68
68
69 md.inlinePatterns[u'autolink_ext'] = autolink
69 md.inlinePatterns[u'autolink_ext'] = autolink
70 md.inlinePatterns.add(u'reflink', reflink, '<entity')
70 md.inlinePatterns.add(u'reflink', reflink, '<entity')
71 md.inlinePatterns.add(u'quote', quote, '<entity')
71 md.inlinePatterns.add(u'quote', quote, '<entity')
72 md.inlinePatterns[u'spoiler'] = spoiler
72 md.inlinePatterns[u'spoiler'] = spoiler
73 md.inlinePatterns[u'comment'] = comment
73 md.inlinePatterns[u'comment'] = comment
74
74
75
75
76 def makeExtension(configs=None):
76 def makeExtension(configs=None):
77 return NeboardMarkdown(configs=configs)
77 return NeboardMarkdown(configs=configs)
78
78
79 neboard_extension = makeExtension()
79 neboard_extension = makeExtension()
80
80
81
81
82 def markdown_extended(markup):
82 def markdown_extended(markup):
83 return markdown.markdown(markup, [neboard_extension])
83 return markdown.markdown(markup, [neboard_extension])
@@ -1,199 +1,203 b''
1 html {
1 html {
2 background: #555;
2 background: #555;
3 color: #ffffff;
3 color: #ffffff;
4 }
4 }
5
5
6 #admin_panel {
6 #admin_panel {
7 background: #FF0000;
7 background: #FF0000;
8 color: #00FF00
8 color: #00FF00
9 }
9 }
10
10
11 .title {
11 .title {
12 font-weight: bold;
12 font-weight: bold;
13 color: #ffcc00;
13 color: #ffcc00;
14 }
14 }
15
15
16 .link, a {
16 .link, a {
17 color: #afdcec;
17 color: #afdcec;
18 }
18 }
19
19
20 .block {
20 .block {
21 display: inline-block;
21 display: inline-block;
22 vertical-align: top;
22 vertical-align: top;
23 }
23 }
24
24
25 .tag {
25 .tag {
26 color: #b4cfec;
26 color: #b4cfec;
27 }
27 }
28
28
29 .post_id {
29 .post_id {
30 color: #fff380;
30 color: #fff380;
31 }
31 }
32
32
33 .post, .dead_post {
33 .post, .dead_post {
34 background: #333;
34 background: #333;
35 margin: 5px;
35 margin: 5px;
36 padding: 10px;
36 padding: 10px;
37 border-radius: 5px;
37 border-radius: 5px;
38 clear: left;
38 clear: left;
39 }
39 }
40
40
41 .metadata {
41 .metadata {
42 padding: 5px;
42 padding: 5px;
43 margin-top: 10px;
43 margin-top: 10px;
44 border: solid 1px #666;
44 border: solid 1px #666;
45 font-size: 0.9em;
45 font-size: 0.9em;
46 color: #ddd;
46 color: #ddd;
47 display: table;
47 display: table;
48 }
48 }
49
49
50 .navigation_panel {
50 .navigation_panel {
51 background: #444;
51 background: #444;
52 margin: 5px;
52 margin: 5px;
53 padding: 10px;
53 padding: 10px;
54 border-radius: 5px;
54 border-radius: 5px;
55 color: #eee;
55 color: #eee;
56 }
56 }
57
57
58 .navigation_panel .link {
58 .navigation_panel .link {
59 border-right: 1px solid #fff;
59 border-right: 1px solid #fff;
60 font-weight: bold;
60 font-weight: bold;
61 margin-right: 1ex;
61 margin-right: 1ex;
62 padding-right: 1ex;
62 padding-right: 1ex;
63 }
63 }
64 .navigation_panel .link:last-child {
64 .navigation_panel .link:last-child {
65 border-left: 1px solid #fff;
65 border-left: 1px solid #fff;
66 border-right: none;
66 border-right: none;
67 float: right;
67 float: right;
68 margin-left: 1ex;
68 margin-left: 1ex;
69 margin-right: 0;
69 margin-right: 0;
70 padding-left: 1ex;
70 padding-left: 1ex;
71 padding-right: 0;
71 padding-right: 0;
72 }
72 }
73
73
74 .navigation_panel::after, .post::after {
74 .navigation_panel::after, .post::after {
75 clear: both;
75 clear: both;
76 content: ".";
76 content: ".";
77 display: block;
77 display: block;
78 height: 0;
78 height: 0;
79 line-height: 0;
79 line-height: 0;
80 visibility: hidden;
80 visibility: hidden;
81 }
81 }
82
82
83 p {
83 p {
84 margin-top: .5em;
84 margin-top: .5em;
85 margin-bottom: .5em;
85 margin-bottom: .5em;
86 }
86 }
87
87
88 .post-form-w {
88 .post-form-w {
89 display: table;
89 display: table;
90 background: #333344;
90 background: #333344;
91 border-radius: 5px;
91 border-radius: 5px;
92 color: #fff;
92 color: #fff;
93 padding: 10px;
93 padding: 10px;
94 margin: 5px
94 margin: 5px
95 }
95 }
96
96
97 .form-row {
97 .form-row {
98 display: table-row;
98 display: table-row;
99 }
99 }
100
100
101 .form-label, .form-input {
101 .form-label, .form-input {
102 display: table-cell;
102 display: table-cell;
103 }
103 }
104
104
105 .form-label {
105 .form-label {
106 padding: .25em 1ex .25em 0;
106 padding: .25em 1ex .25em 0;
107 vertical-align: top;
107 vertical-align: top;
108 }
108 }
109
109
110 .form-input {
110 .form-input {
111 padding: .25em 0;
111 padding: .25em 0;
112 }
112 }
113
113
114 .post-form input, .post-form textarea {
114 .post-form input, .post-form textarea {
115 background: #333;
115 background: #333;
116 color: #fff;
116 color: #fff;
117 border: solid 1px;
117 border: solid 1px;
118 padding: 0;
118 padding: 0;
119 width: 100%;
119 width: 100%;
120 }
120 }
121
121
122 .form-submit {
122 .form-submit {
123 border-bottom: 2px solid #ddd;
123 border-bottom: 2px solid #ddd;
124 margin-bottom: .5em;
124 margin-bottom: .5em;
125 padding-bottom: .5em;
125 padding-bottom: .5em;
126 }
126 }
127
127
128 .form-title {
128 .form-title {
129 font-weight: bold;
129 font-weight: bold;
130 }
130 }
131
131
132 input[type="submit"] {
132 input[type="submit"] {
133 background: #222;
133 background: #222;
134 border: solid 1px #fff;
134 border: solid 1px #fff;
135 color: #fff;
135 color: #fff;
136 }
136 }
137
137
138 blockquote {
138 blockquote {
139 border-left: solid 2px;
139 border-left: solid 2px;
140 padding-left: 5px;
140 padding-left: 5px;
141 color: #B1FB17;
141 color: #B1FB17;
142 margin: 0;
142 margin: 0;
143 }
143 }
144
144
145 .post > .image {
145 .post > .image {
146 float: left; margin: 0 1ex .5ex 0;
146 float: left; margin: 0 1ex .5ex 0;
147 }
147 }
148
148
149 .post > .metadata {
149 .post > .metadata {
150 clear: left;
150 clear: left;
151 }
151 }
152
152
153 .get {
153 .get {
154 font-weight: bold;
154 font-weight: bold;
155 color: #d55;
155 color: #d55;
156 }
156 }
157
157
158 * {
158 * {
159 text-decoration: none;
159 text-decoration: none;
160 }
160 }
161
161
162 .dead_post {
162 .dead_post {
163 background-color: #442222;
163 background-color: #442222;
164 }
164 }
165
165
166 .quote {
166 .quote {
167 color: greenyellow;
167 color: greenyellow;
168 padding-left: 5px;
168 padding-left: 5px;
169 border-left: solid 2px greenyellow;
169 border-left: solid 2px greenyellow;
170 }
170 }
171
171
172 .spoiler {
172 .spoiler {
173 background: white;
173 background: white;
174 color: white;
174 color: white;
175 }
175 }
176
176
177 .spoiler:hover {
177 .spoiler:hover {
178 background: black;
178 background: black;
179 }
179 }
180
180
181 .comment {
181 .comment {
182 color: darkseagreen;
182 color: darkseagreen;
183 }
183 }
184
184
185 a:hover {
185 a:hover {
186 text-decoration: underline;
186 text-decoration: underline;
187 }
187 }
188
188
189 .last-replies {
189 .last-replies {
190 margin-left: 3ex;
190 margin-left: 3ex;
191 }
191 }
192
192
193 .thread {
193 .thread {
194 margin-bottom: 3ex;
194 margin-bottom: 3ex;
195 }
195 }
196
196
197 .post:target {
197 .post:target {
198 border: solid 2px white;
198 border: solid 2px white;
199 }
200
201 pre{
202 white-space:pre-wrap
199 } No newline at end of file
203 }
@@ -1,214 +1,220 b''
1 * {
1 * {
2 font-size: inherit;
2 font-size: inherit;
3 margin: 0;
3 margin: 0;
4 padding: 0;
4 padding: 0;
5 }
5 }
6 html {
6 html {
7 background: #fff;
7 background: #fff;
8 color: #000;
8 color: #000;
9 font: medium sans-serif;
9 font: medium sans-serif;
10 }
10 }
11 a {
11 a {
12 color: inherit;
12 color: inherit;
13 text-decoration: underline;
13 text-decoration: underline;
14 }
14 }
15
15
16 #admin_panel {
16 #admin_panel {
17 background: #182F6F;
17 background: #182F6F;
18 color: #fff;
18 color: #fff;
19 padding: .5ex 1ex .5ex 1ex;
19 padding: .5ex 1ex .5ex 1ex;
20 }
20 }
21
21
22 .navigation_panel {
22 .navigation_panel {
23 background: #182F6F;
23 background: #182F6F;
24 color: #B4CFEC;
24 color: #B4CFEC;
25 margin-bottom: 1em;
25 margin-bottom: 1em;
26 padding: .5ex 1ex 1ex 1ex;
26 padding: .5ex 1ex 1ex 1ex;
27 }
27 }
28 .navigation_panel::after {
28 .navigation_panel::after {
29 clear: both;
29 clear: both;
30 content: ".";
30 content: ".";
31 display: block;
31 display: block;
32 height: 0;
32 height: 0;
33 line-height: 0;
33 line-height: 0;
34 visibility: hidden;
34 visibility: hidden;
35 }
35 }
36
36
37 .navigation_panel a:link, .navigation_panel a:visited, .navigation_panel a:hover {
37 .navigation_panel a:link, .navigation_panel a:visited, .navigation_panel a:hover {
38 text-decoration: none;
38 text-decoration: none;
39 }
39 }
40
40
41 .navigation_panel .link {
41 .navigation_panel .link {
42 border-right: 1px solid #fff;
42 border-right: 1px solid #fff;
43 color: #fff;
43 color: #fff;
44 font-weight: bold;
44 font-weight: bold;
45 margin-right: 1ex;
45 margin-right: 1ex;
46 padding-right: 1ex;
46 padding-right: 1ex;
47 }
47 }
48 .navigation_panel .link:last-child {
48 .navigation_panel .link:last-child {
49 border-left: 1px solid #fff;
49 border-left: 1px solid #fff;
50 border-right: none;
50 border-right: none;
51 float: right;
51 float: right;
52 margin-left: 1ex;
52 margin-left: 1ex;
53 margin-right: 0;
53 margin-right: 0;
54 padding-left: 1ex;
54 padding-left: 1ex;
55 padding-right: 0;
55 padding-right: 0;
56 }
56 }
57
57
58 .navigation_panel .tag {
58 .navigation_panel .tag {
59 color: #fff;
59 color: #fff;
60 }
60 }
61
61
62 .title {
62 .title {
63 color: #182F6F;
63 color: #182F6F;
64 font-weight: bold;
64 font-weight: bold;
65 }
65 }
66
66
67 .post-form-w {
67 .post-form-w {
68 background: #182F6F;
68 background: #182F6F;
69 border-radius: 1ex;
69 border-radius: 1ex;
70 color: #fff;
70 color: #fff;
71 margin: 1em 1ex;
71 margin: 1em 1ex;
72 padding: 1ex;
72 padding: 1ex;
73 }
73 }
74 .post-form {
74 .post-form {
75 display: table;
75 display: table;
76 border-collapse: collapse;
76 border-collapse: collapse;
77 width: 100%;
77 width: 100%;
78
78
79 }
79 }
80 .form-row {
80 .form-row {
81 display: table-row;
81 display: table-row;
82 }
82 }
83 .form-label, .form-input {
83 .form-label, .form-input {
84 display: table-cell;
84 display: table-cell;
85 vertical-align: top;
85 vertical-align: top;
86 }
86 }
87 .form-label {
87 .form-label {
88 padding: .25em 1ex .25em 0;
88 padding: .25em 1ex .25em 0;
89 }
89 }
90 .form-input {
90 .form-input {
91 padding: .25em 0;
91 padding: .25em 0;
92 }
92 }
93 .form-input > * {
93 .form-input > * {
94 background: #fff;
94 background: #fff;
95 color: #000;
95 color: #000;
96 border: none;
96 border: none;
97 padding: 0;
97 padding: 0;
98 resize: vertical;
98 resize: vertical;
99 width: 100%;
99 width: 100%;
100 }
100 }
101 .form-submit {
101 .form-submit {
102 border-bottom: 1px solid #666;
102 border-bottom: 1px solid #666;
103 margin-bottom: .5em;
103 margin-bottom: .5em;
104 padding-bottom: .5em;
104 padding-bottom: .5em;
105 }
105 }
106 .form-title {
106 .form-title {
107 font-weight: bold;
107 font-weight: bold;
108 margin-bottom: .5em;
108 margin-bottom: .5em;
109 }
109 }
110 .post-form .settings_item {
110 .post-form .settings_item {
111 margin: .5em 0;
111 margin: .5em 0;
112 }
112 }
113 .form-submit input {
113 .form-submit input {
114 margin-top: .5em;
114 margin-top: .5em;
115 padding: .2em 1ex;
115 padding: .2em 1ex;
116 }
116 }
117 .form-label {
117 .form-label {
118 text-align: right;
118 text-align: right;
119 }
119 }
120
120
121 .block {
121 .block {
122 display: inline-block;
122 display: inline-block;
123 vertical-align: top;
123 vertical-align: top;
124 }
124 }
125
125
126 .post_id {
126 .post_id {
127 color: #a00;
127 color: #a00;
128 }
128 }
129
129
130 .post {
130 .post {
131 clear: left;
131 clear: left;
132 margin: 0 1ex 1em 1ex;
132 margin: 0 1ex 1em 1ex;
133 overflow-x: auto;
133 overflow-x: auto;
134 }
134 }
135 .last-replies > .post, body > .post + .post {
135 .last-replies > .post, body > .post + .post {
136 border-bottom: 1px solid #182F6F;
136 border-bottom: 1px solid #182F6F;
137 padding-bottom: 1em;
137 padding-bottom: 1em;
138 }
138 }
139
139
140 .metadata {
140 .metadata {
141 background: #C0E4E8;
141 background: #C0E4E8;
142 border: 1px solid #7F9699;
142 border: 1px solid #7F9699;
143 border-radius: .4ex;
143 border-radius: .4ex;
144 display: table;
144 display: table;
145 margin-top: .5em;
145 margin-top: .5em;
146 padding: .4em;
146 padding: .4em;
147 }
147 }
148
148
149 .post ul, .post ol {
149 .post ul, .post ol {
150 margin: .5em 0 .5em 3ex;
150 margin: .5em 0 .5em 3ex;
151 }
151 }
152 .post li {
152 .post li {
153 margin: .2em 0;
153 margin: .2em 0;
154 }
154 }
155 .post p {
155 .post p {
156 margin: .5em 0;
156 margin: .5em 0;
157 }
157 }
158 .post blockquote {
158 .post blockquote {
159 border-left: 3px solid #182F6F;
159 border-left: 3px solid #182F6F;
160 margin: .5em 0 .5em 3ex;
160 margin: .5em 0 .5em 3ex;
161 padding-left: 1ex;
161 padding-left: 1ex;
162 }
162 }
163 .post blockquote > blockquote {
163 .post blockquote > blockquote {
164 padding-top: .1em;
164 padding-top: .1em;
165 }
165 }
166
166
167 .post > .image {
167 .post > .image {
168 float: left;
168 float: left;
169 margin-right: 1ex;
169 margin-right: 1ex;
170 }
170 }
171 .post > .metadata {
171 .post > .metadata {
172 clear: left;
172 clear: left;
173 }
173 }
174
174
175 .post > .message .get {
175 .post > .message .get {
176 color: #182F6F; font-weight: bold;
176 color: #182F6F; font-weight: bold;
177 }
177 }
178
178
179 .dead_post > .metadata {
179 .dead_post > .metadata {
180 background: #eee;
180 background: #eee;
181 }
181 }
182
182
183 .quote {
183 .quote {
184 color: #182F6F;
184 color: #182F6F;
185 padding-left: 5px;
185 padding-left: 5px;
186 border-left: solid 2px blue;
186 border-left: solid 2px blue;
187 }
187 }
188
188
189 .spoiler {
189 .spoiler {
190 background: black;
190 background: black;
191 color: black;
191 color: black;
192 }
192 }
193
193
194 .spoiler:hover {
194 .spoiler:hover {
195 background: #ffffff;
195 background: #ffffff;
196 }
196 }
197
197
198 .comment {
198 .comment {
199 color: #557055;
199 color: #557055;
200 }
200 }
201
201
202 .last-replies {
202 .last-replies {
203 margin-left: 6ex;
203 margin-left: 6ex;
204 }
204 }
205
205
206 .thread > .post > .message > .post-info {
206 .thread > .post > .message > .post-info {
207 border-bottom: 2px solid #182F6F;
207 border-bottom: 2px solid #182F6F;
208 padding-bottom: .5em;
208 padding-bottom: .5em;
209 }
209 }
210
210
211 .last-replies > .post:last-child {
211 .last-replies > .post:last-child {
212 border-bottom: none;
212 border-bottom: none;
213 padding-bottom: 0;
213 padding-bottom: 0;
214 }
215
216 :target .post_id {
217 background: #182F6F;
218 color: #FFF;
219 text-decoration: none;
214 } No newline at end of file
220 }
General Comments 0
You need to be logged in to leave comments. Login now