##// END OF EJS Templates
#38 Added smooth scroll to up with jQuery. #12 Fixed parsing of entities (quotes etc).
neko259 -
r55:f0afaf96 default
parent child Browse files
Show More
@@ -1,61 +1,63 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 NeboardMarkdown(markdown.Extension):
37 class NeboardMarkdown(markdown.Extension):
38 AUTOLINK_PATTERN = r'(http://\S+)'
38 AUTOLINK_PATTERN = r'(http://\S+)'
39 QUOTE_PATTERN = r'(>){1}(.+)'
39 QUOTE_PATTERN = r'(>){1}(.+)'
40 REFLINK_PATTERN = r'((>){2}(\d+))'
40 REFLINK_PATTERN = r'((>){2}(\d+))'
41
41
42 def extendMarkdown(self, md, md_globals):
42 def extendMarkdown(self, md, md_globals):
43 autolink = AutolinkPattern(self.AUTOLINK_PATTERN, md)
43 autolink = AutolinkPattern(self.AUTOLINK_PATTERN, md)
44 quote = QuotePattern(self.QUOTE_PATTERN, md)
44 quote = QuotePattern(self.QUOTE_PATTERN, md)
45 reflink = ReflinkPattern(self.REFLINK_PATTERN, md)
45 reflink = ReflinkPattern(self.REFLINK_PATTERN, md)
46
46
47 md.inlinePatterns[u'autolink_ext'] = autolink
47 md.inlinePatterns[u'autolink_ext'] = autolink
48 md.inlinePatterns[u'reflink'] = reflink
48 md.inlinePatterns.add(u'reflink', reflink, '<entity')
49 md.inlinePatterns[u'quote'] = quote
49 md.inlinePatterns.add(u'quote', quote, '<entity')
50 # md.inlinePatterns[u'reflink'] = reflink
51 # md.inlinePatterns[u'quote'] = quote
50
52
51 del(md.inlinePatterns[u'entity'])
53 # del(md.inlinePatterns[u'entity'])
52
54
53
55
54 def makeExtension(configs=None):
56 def makeExtension(configs=None):
55 return NeboardMarkdown(configs=configs)
57 return NeboardMarkdown(configs=configs)
56
58
57 neboard_extension = makeExtension()
59 neboard_extension = makeExtension()
58
60
59
61
60 def markdown_extended(markup):
62 def markdown_extended(markup):
61 return markdown.markdown(markup, [neboard_extension])
63 return markdown.markdown(markup, [neboard_extension])
@@ -1,182 +1,182 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 .link:hover {
20 .link:hover, a:hover {
21 color: #fff380;
21 color: #fff380;
22 }
22 }
23
23
24 .post_id:hover {
24 .post_id:hover {
25 color: #ccc555;
25 color: #ccc555;
26 }
26 }
27
27
28 .block {
28 .block {
29 display: inline-block;
29 display: inline-block;
30 vertical-align: top;
30 vertical-align: top;
31 }
31 }
32
32
33 .tag {
33 .tag {
34 color: #b4cfec;
34 color: #b4cfec;
35 }
35 }
36
36
37 .tag:hover {
37 .tag:hover {
38 color: #d0edb4;
38 color: #d0edb4;
39 }
39 }
40
40
41 .post_id {
41 .post_id {
42 color: #fff380;
42 color: #fff380;
43 }
43 }
44
44
45 .post, .dead_post{
45 .post, .dead_post{
46 background: #333;
46 background: #333;
47 margin: 5px;
47 margin: 5px;
48 padding: 10px;
48 padding: 10px;
49 border-radius: 5px;
49 border-radius: 5px;
50 clear: left;
50 clear: left;
51 }
51 }
52
52
53 .metadata {
53 .metadata {
54 padding: 5px;
54 padding: 5px;
55 margin-top: 10px;
55 margin-top: 10px;
56 border: solid 1px #666;
56 border: solid 1px #666;
57 font-size: 0.9em;
57 font-size: 0.9em;
58 color: #ddd;
58 color: #ddd;
59 display: table;
59 display: table;
60 }
60 }
61
61
62 .navigation_panel {
62 .navigation_panel {
63 background: #444;
63 background: #444;
64 margin: 5px;
64 margin: 5px;
65 padding: 10px;
65 padding: 10px;
66 border-radius: 5px;
66 border-radius: 5px;
67 color: #eee;
67 color: #eee;
68 }
68 }
69
69
70 .navigation_panel .link {
70 .navigation_panel .link {
71 border-right: 1px solid #fff;
71 border-right: 1px solid #fff;
72 font-weight: bold;
72 font-weight: bold;
73 margin-right: 1ex;
73 margin-right: 1ex;
74 padding-right: 1ex;
74 padding-right: 1ex;
75 }
75 }
76 .navigation_panel .link:last-child {
76 .navigation_panel .link:last-child {
77 border-left: 1px solid #fff;
77 border-left: 1px solid #fff;
78 border-right: none;
78 border-right: none;
79 float: right;
79 float: right;
80 margin-left: 1ex;
80 margin-left: 1ex;
81 margin-right: 0;
81 margin-right: 0;
82 padding-left: 1ex;
82 padding-left: 1ex;
83 padding-right: 0;
83 padding-right: 0;
84 }
84 }
85
85
86 .navigation_panel::after, .post::after {
86 .navigation_panel::after, .post::after {
87 clear: both;
87 clear: both;
88 content: ".";
88 content: ".";
89 display: block;
89 display: block;
90 height: 0;
90 height: 0;
91 line-height: 0;
91 line-height: 0;
92 visibility: hidden;
92 visibility: hidden;
93 }
93 }
94
94
95 p {
95 p {
96 margin-top: .5em;
96 margin-top: .5em;
97 margin-bottom: .5em;
97 margin-bottom: .5em;
98 }
98 }
99
99
100 .post-form-w {
100 .post-form-w {
101 display: table;
101 display: table;
102 background: #333344;
102 background: #333344;
103 border-radius: 5px;
103 border-radius: 5px;
104 color: #fff;
104 color: #fff;
105 padding: 10px;
105 padding: 10px;
106 margin: 5px
106 margin: 5px
107 }
107 }
108
108
109 .form-row {
109 .form-row {
110 display: table-row;
110 display: table-row;
111 }
111 }
112
112
113 .form-label, .form-input {
113 .form-label, .form-input {
114 display: table-cell;
114 display: table-cell;
115 }
115 }
116
116
117 .form-label {
117 .form-label {
118 padding: .25em 1ex .25em 0;
118 padding: .25em 1ex .25em 0;
119 vertical-align: top;
119 vertical-align: top;
120 }
120 }
121
121
122 .form-input {
122 .form-input {
123 padding: .25em 0;
123 padding: .25em 0;
124 }
124 }
125
125
126 .post-form input, .post-form textarea {
126 .post-form input, .post-form textarea {
127 background: #333;
127 background: #333;
128 color: #fff;
128 color: #fff;
129 border: solid 1px;
129 border: solid 1px;
130 padding: 0;
130 padding: 0;
131 width: 100%;
131 width: 100%;
132 }
132 }
133
133
134 .form-submit {
134 .form-submit {
135 border-bottom: 2px solid #ddd;
135 border-bottom: 2px solid #ddd;
136 margin-bottom: .5em;
136 margin-bottom: .5em;
137 padding-bottom: .5em;
137 padding-bottom: .5em;
138 }
138 }
139
139
140 .form-title {
140 .form-title {
141 font-weight: bold;
141 font-weight: bold;
142 }
142 }
143
143
144 input[type="submit"] {
144 input[type="submit"] {
145 background: #222;
145 background: #222;
146 border: solid 1px #fff;
146 border: solid 1px #fff;
147 color: #fff;
147 color: #fff;
148 }
148 }
149
149
150 blockquote {
150 blockquote {
151 border-left: solid 2px;
151 border-left: solid 2px;
152 padding-left: 5px;
152 padding-left: 5px;
153 color: #B1FB17;
153 color: #B1FB17;
154 margin: 0;
154 margin: 0;
155 }
155 }
156
156
157 .post > .image {
157 .post > .image {
158 float: left; margin: 0 1ex .5ex 0;
158 float: left; margin: 0 1ex .5ex 0;
159 }
159 }
160
160
161 .post > .metadata {
161 .post > .metadata {
162 clear: left;
162 clear: left;
163 }
163 }
164
164
165 .get {
165 .get {
166 font-weight: bold;
166 font-weight: bold;
167 color: #d55;
167 color: #d55;
168 }
168 }
169
169
170 * {
170 * {
171 text-decoration: none;
171 text-decoration: none;
172 }
172 }
173
173
174 .dead_post {
174 .dead_post {
175 background-color: #442222;
175 background-color: #442222;
176 }
176 }
177
177
178 .quote {
178 .quote {
179 color: greenyellow;
179 color: greenyellow;
180 padding-left: 5px;
180 padding-left: 5px;
181 border-left: solid 2px greenyellow;
181 border-left: solid 2px greenyellow;
182 } No newline at end of file
182 }
General Comments 0
You need to be logged in to leave comments. Login now