Dynastie

Dynastie Commit Details

Date:2016-03-19 17:03:43 (4 years 4 months ago)
Author:Grégory Soutadé
Branch:master
Commit:8bf132976d49c38fdff02163993f2e3cf9c6ec88
Parents: 97176ed45438d07d4f88ac1a3274f1fb8c7132dc
Message:Read posts with unicode instead binary

Changes:
Mdynastie/generators/index.py (7 diffs)
Mdynastie/sites/blog.soutade.fr/_ljdc.xml (1 diff)

File differences

dynastie/generators/index.py
2525
2626
2727
28
2829
2930
3031
......
202203
203204
204205
205
206
207
208
209
206210
207211
208212
......
210214
211215
212216
213
214217
215218
216219
......
246249
247250
248251
249
252
253
250254
251255
252256
......
267271
268272
269273
270
274
271275
272276
273277
......
287291
288292
289293
290
294
291295
292296
293297
......
498502
499503
500504
501
505
502506
503507
504508
from xml.parsers.expat import *
import xml.parsers.expat
from xml.dom.minidom import parse, parseString
import codecs
from dynastie.generators.generator import DynastieGenerator, StrictUTF8Writer
from django.db import models
from dynastie.generators import markdown2
break
try:
dom = parseString(code[start:end+11])
try:
dom = parseString(code[start:end+11])
except UnicodeEncodeError:
dom = parseString(code[start:end+11].encode('utf-8'))
except xml.dom.DOMException as e:
self.addError('Error parsing ' + self.filename)
break
res = self.createCode(dom, dom.firstChild)
if res:
code = code.replace(code[start:end+11], res)
return code
def _have_I_right(self, user, post_id):
if not post: continue
new_content = self._loadPostContent(post)
if new_content:
text = text.replace('[[' + str(post_id) + ']]', new_content)
p = '[[' + str(post_id) + ']]'
text = text.replace(p, new_content)
if internal_posts: return text
# HTML replace
if not post or (post and post.content_format == Post.CONTENT_HTML):
if not post: break
new_content = self._loadPostContent(post)
if new_content:
text = text.replace(text[start:end+18], new_content.encode('utf-8'))
text = text.replace(text[start:end+18], new_content)
return text
def _loadPostContent(self, post):
filename = filename2
if not filename in self.hash_posts_content:
f = open(filename, 'rb')
f = codecs.open(filename, 'rb', 'utf-8')
post_content = f.read()
f.close()
self.parent_posts.append(post.id)
# Remove <pre> after <div class="highlight">
code = code[28:-13]
code = '<div class="highlight">' + code + '</div>'
code = u'<div class="highlight">' + unicode(code, 'utf-8') + u'</div>'
return code
dynastie/sites/blog.soutade.fr/_ljdc.xml
11
22
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
321
422
523
<?xml version="1.0" encoding="utf-8"?>
<ljdc>
<entry>
<id>138932499327</id>
<address>http://thecodinglove.com/post/138932499327/seeing-my-own-code-after-years</address>
<title>Seeing my own code after years</title>
<img>http://tclhost.com/nDmdJau.gif</img>
</entry>
<entry>
<id>137804239758</id>
<address>http://thecodinglove.com/post/137804239758/when-you-discover-a-serious-bug-during-a-client</address>
<title>When you discover a serious bug during a client...</title>
<img>http://tclhost.com/rzUXIEl.gif</img>
</entry>
<entry>
<id>137344478111</id>
<address>http://thecodinglove.com/post/137344478111/arriving-late-to-an-important-meeting</address>
<title>Arriving late to an important meeting</title>
<img>http://tclhost.com/CXW1sJ4.gif</img>
</entry>
<entry>
<id>132019829293</id>
<address>http://thecodinglove.com/post/132019829293/when-a-mad-boss-looking-for-me-enters-the-open</address>

Archive Download the corresponding diff file

Branches

Tags