Permalink
Browse files

A lot of new stuff are in. And I'm working on next version.

  • Loading branch information...
1 parent 52de7ba commit 836a2454be8567cebe23fc893e644bcd770ab677 @livid committed Mar 20, 2012
Showing with 88,464 additions and 275 deletions.
  1. +32 −0 feed.py
  2. +17 −0 html5lib/__init__.py
  3. +3,085 −0 html5lib/constants.py
  4. 0 html5lib/filters/__init__.py
  5. +10 −0 html5lib/filters/_base.py
  6. +127 −0 html5lib/filters/formfiller.py
  7. +62 −0 html5lib/filters/inject_meta_charset.py
  8. +88 −0 html5lib/filters/lint.py
  9. +202 −0 html5lib/filters/optionaltags.py
  10. +8 −0 html5lib/filters/sanitizer.py
  11. +41 −0 html5lib/filters/whitespace.py
  12. +2,733 −0 html5lib/html5parser.py
  13. +177 −0 html5lib/ihatexml.py
  14. +782 −0 html5lib/inputstream.py
  15. +258 −0 html5lib/sanitizer.py
  16. +17 −0 html5lib/serializer/__init__.py
  17. +312 −0 html5lib/serializer/htmlserializer.py
  18. +9 −0 html5lib/serializer/xhtmlserializer.py
  19. +12 −0 html5lib/tests/__init__.py
  20. +37 −0 html5lib/tests/mockParser.py
  21. +27 −0 html5lib/tests/runparsertests.py
  22. +20 −0 html5lib/tests/runtests.py
  23. +127 −0 html5lib/tests/support.py
  24. +54 −0 html5lib/tests/test_encoding.py
  25. +296 −0 html5lib/tests/test_formfiller.py
  26. +140 −0 html5lib/tests/test_parser.py
  27. +39 −0 html5lib/tests/test_parser2.py
  28. +76 −0 html5lib/tests/test_sanitizer.py
  29. +180 −0 html5lib/tests/test_serializer.py
  30. +97 −0 html5lib/tests/test_stream.py
  31. +193 −0 html5lib/tests/test_tokenizer.py
  32. +311 −0 html5lib/tests/test_treewalkers.py
  33. +123 −0 html5lib/tests/test_whitespace_filter.py
  34. +10 −0 html5lib/tests/testdata/encoding/test-yahoo-jp.dat
  35. +394 −0 html5lib/tests/testdata/encoding/tests1.dat
  36. +115 −0 html5lib/tests/testdata/encoding/tests2.dat
  37. +501 −0 html5lib/tests/testdata/sanitizer/tests1.dat
  38. +125 −0 html5lib/tests/testdata/serializer/core.test
  39. +66 −0 html5lib/tests/testdata/serializer/injectmeta.test
  40. +965 −0 html5lib/tests/testdata/serializer/optionaltags.test
  41. +60 −0 html5lib/tests/testdata/serializer/options.test
  42. +51 −0 html5lib/tests/testdata/serializer/whitespace.test
  43. +43 −0 html5lib/tests/testdata/sniffer/htmlOrFeed.json
  44. +75 −0 html5lib/tests/testdata/tokenizer/contentModelFlags.test
  45. +90 −0 html5lib/tests/testdata/tokenizer/domjs.test
  46. +283 −0 html5lib/tests/testdata/tokenizer/entities.test
  47. +33 −0 html5lib/tests/testdata/tokenizer/escapeFlag.test
  48. +44,189 −0 html5lib/tests/testdata/tokenizer/namedEntities.test
  49. +1,313 −0 html5lib/tests/testdata/tokenizer/numericEntities.test
  50. +7 −0 html5lib/tests/testdata/tokenizer/pendingSpecChanges.test
  51. +196 −0 html5lib/tests/testdata/tokenizer/test1.test
  52. +179 −0 html5lib/tests/testdata/tokenizer/test2.test
  53. +6,047 −0 html5lib/tests/testdata/tokenizer/test3.test
  54. +344 −0 html5lib/tests/testdata/tokenizer/test4.test
  55. +1,295 −0 html5lib/tests/testdata/tokenizer/unicodeChars.test
  56. +27 −0 html5lib/tests/testdata/tokenizer/unicodeCharsProblematic.test
  57. +22 −0 html5lib/tests/testdata/tokenizer/xmlViolation.test
  58. +194 −0 html5lib/tests/testdata/tree-construction/adoption01.dat
  59. +31 −0 html5lib/tests/testdata/tree-construction/adoption02.dat
  60. +135 −0 html5lib/tests/testdata/tree-construction/comments01.dat
  61. +370 −0 html5lib/tests/testdata/tree-construction/doctype01.dat
  62. BIN html5lib/tests/testdata/tree-construction/domjs-unsafe.dat
  63. +603 −0 html5lib/tests/testdata/tree-construction/entities01.dat
  64. +249 −0 html5lib/tests/testdata/tree-construction/entities02.dat
  65. +246 −0 html5lib/tests/testdata/tree-construction/html5test-com.dat
  66. +43 −0 html5lib/tests/testdata/tree-construction/inbody01.dat
  67. +40 −0 html5lib/tests/testdata/tree-construction/isindex.dat
  68. BIN html5lib/tests/testdata/tree-construction/pending-spec-changes-plain-text-unsafe.dat
  69. +52 −0 html5lib/tests/testdata/tree-construction/pending-spec-changes.dat
  70. BIN html5lib/tests/testdata/tree-construction/plain-text-unsafe.dat
  71. +308 −0 html5lib/tests/testdata/tree-construction/scriptdata01.dat
  72. +212 −0 html5lib/tests/testdata/tree-construction/tables01.dat
  73. +1,952 −0 html5lib/tests/testdata/tree-construction/tests1.dat
  74. +799 −0 html5lib/tests/testdata/tree-construction/tests10.dat
  75. +482 −0 html5lib/tests/testdata/tree-construction/tests11.dat
  76. +62 −0 html5lib/tests/testdata/tree-construction/tests12.dat
  77. +74 −0 html5lib/tests/testdata/tree-construction/tests14.dat
  78. +208 −0 html5lib/tests/testdata/tree-construction/tests15.dat
  79. +2,299 −0 html5lib/tests/testdata/tree-construction/tests16.dat
  80. +153 −0 html5lib/tests/testdata/tree-construction/tests17.dat
  81. +269 −0 html5lib/tests/testdata/tree-construction/tests18.dat
  82. +1,237 −0 html5lib/tests/testdata/tree-construction/tests19.dat
  83. +763 −0 html5lib/tests/testdata/tree-construction/tests2.dat
  84. +455 −0 html5lib/tests/testdata/tree-construction/tests20.dat
  85. +221 −0 html5lib/tests/testdata/tree-construction/tests21.dat
  86. +157 −0 html5lib/tests/testdata/tree-construction/tests22.dat
  87. +155 −0 html5lib/tests/testdata/tree-construction/tests23.dat
  88. +79 −0 html5lib/tests/testdata/tree-construction/tests24.dat
  89. +219 −0 html5lib/tests/testdata/tree-construction/tests25.dat
  90. +313 −0 html5lib/tests/testdata/tree-construction/tests26.dat
  91. +305 −0 html5lib/tests/testdata/tree-construction/tests3.dat
  92. +59 −0 html5lib/tests/testdata/tree-construction/tests4.dat
  93. +191 −0 html5lib/tests/testdata/tree-construction/tests5.dat
  94. +663 −0 html5lib/tests/testdata/tree-construction/tests6.dat
  95. +390 −0 html5lib/tests/testdata/tree-construction/tests7.dat
  96. +148 −0 html5lib/tests/testdata/tree-construction/tests8.dat
  97. +457 −0 html5lib/tests/testdata/tree-construction/tests9.dat
  98. +741 −0 html5lib/tests/testdata/tree-construction/tests_innerHTML_1.dat
  99. +261 −0 html5lib/tests/testdata/tree-construction/tricky01.dat
  100. +594 −0 html5lib/tests/testdata/tree-construction/webkit01.dat
  101. +94 −0 html5lib/tests/testdata/tree-construction/webkit02.dat
  102. +64 −0 html5lib/tests/tokenizertotree.py
  103. +1,744 −0 html5lib/tokenizer.py
  104. +96 −0 html5lib/treebuilders/__init__.py
  105. +377 −0 html5lib/treebuilders/_base.py
  106. +291 −0 html5lib/treebuilders/dom.py
  107. +344 −0 html5lib/treebuilders/etree.py
  108. +336 −0 html5lib/treebuilders/etree_lxml.py
  109. +256 −0 html5lib/treebuilders/simpletree.py
  110. +236 −0 html5lib/treebuilders/soup.py
  111. +52 −0 html5lib/treewalkers/__init__.py
  112. +176 −0 html5lib/treewalkers/_base.py
  113. +41 −0 html5lib/treewalkers/dom.py
  114. +141 −0 html5lib/treewalkers/etree.py
  115. +70 −0 html5lib/treewalkers/genshistream.py
  116. +186 −0 html5lib/treewalkers/lxmletree.py
  117. +60 −0 html5lib/treewalkers/pulldom.py
  118. +78 −0 html5lib/treewalkers/simpletree.py
  119. +60 −0 html5lib/treewalkers/soup.py
  120. +175 −0 html5lib/utils.py
  121. +209 −209 index.yaml
  122. +2 −2 main.py
  123. +34 −0 member.py
  124. +3 −10 static/css/mobile/style.css
  125. +12 −19 tpl/desktop/advertise.html
  126. +59 −1 tpl/desktop/advertisers.html
  127. +2 −2 tpl/desktop/common/bottom.html
  128. +1 −1 tpl/desktop/index.html
  129. +1 −1 tpl/desktop/rightbar/ads.html
  130. +47 −0 tpl/desktop/rightbar/ads_3cpeijian.html
  131. +15 −0 tpl/desktop/rightbar/ads_appletuan2.html
  132. +32 −0 tpl/desktop/rightbar/ads_netease.html
  133. +2 −2 tpl/desktop/rightbar/ads_tangcha.html
  134. +1 −1 tpl/desktop/rightbar/new_topic_tips.html
  135. +2 −2 tpl/feed/index.xml
  136. +24 −0 tpl/feed/read.xml
  137. +4 −0 tpl/mobile/ads/netease.html
  138. +0 −22 tpl/mobile/common/ads.html
  139. +24 −0 tpl/mobile/member_settings.html
  140. +1 −1 tpl/portion/topic_content.html
  141. +1 −1 v2ex/babel/__init__.py
  142. +341 −0 v2ex/babel/ext/bleach/__init__.py
  143. +54 −0 v2ex/babel/ext/bleach/encoding.py
  144. +135 −0 v2ex/babel/ext/bleach/sanitizer.py
  145. +249 −0 v2ex/babel/ext/upyun.py
  146. +21 −1 v2ex/templatetags/filters.py
View
32 feed.py
@@ -52,6 +52,37 @@ def get(self):
self.response.headers['Content-type'] = 'application/xml;charset=UTF-8'
self.response.out.write(output)
+
+class FeedReadHandler(BaseHandler):
+ def head(self):
+ self.response.out.write('')
+
+ def get(self):
+ output = memcache.get('feed_read_output')
+ if output is None:
+ self.values['site_domain'] = self.site.domain
+ self.values['site_name'] = self.site.title
+ self.values['site_slogan'] = self.site.slogan
+ self.values['feed_url'] = 'http://' + self.values['site_domain'] + '/read.xml'
+ self.values['site_updated'] = datetime.datetime.now()
+ topics = memcache.get('feed_home')
+ if topics is None:
+ q = db.GqlQuery("SELECT * FROM Topic ORDER BY created DESC LIMIT 10")
+ topics = []
+ IGNORED = ['newbie', 'in', 'flamewar', 'pointless', 'tuan', '528491', 'chamber', 'autistic', 'blog', 'love', 'flood']
+ for topic in q:
+ if topic.node.name not in IGNORED:
+ topics.append(topic)
+ memcache.set('feed_home', topics, 3600)
+ self.values['topics'] = topics
+ self.values['feed_title'] = self.site.title
+ path = os.path.join(os.path.dirname(__file__), 'tpl', 'feed', 'read.xml')
+ output = template.render(path, self.values)
+ memcache.set('feed_read_output', output, 3600)
+ self.response.headers['Content-type'] = 'application/xml;charset=UTF-8'
+ self.response.out.write(output)
+
+
class FeedNodeHandler(webapp.RequestHandler):
def head(self):
self.response.out.write('')
@@ -86,6 +117,7 @@ def get(self, node_name):
def main():
application = webapp.WSGIApplication([
('/index.xml', FeedHomeHandler),
+ ('/read.xml', FeedReadHandler),
('/feed/v2ex.rss', FeedHomeHandler),
('/feed/([0-9a-zA-Z\-\_]+).xml', FeedNodeHandler)
],
View
@@ -0,0 +1,17 @@
+"""
+HTML parsing library based on the WHATWG "HTML5"
+specification. The parser is designed to be compatible with existing
+HTML found in the wild and implements well-defined error recovery that
+is largely compatible with modern desktop web browsers.
+
+Example usage:
+
+import html5lib
+f = open("my_document.html")
+tree = html5lib.parse(f)
+"""
+__version__ = "0.95-dev"
+from html5parser import HTMLParser, parse, parseFragment
+from treebuilders import getTreeBuilder
+from treewalkers import getTreeWalker
+from serializer import serialize
Oops, something went wrong.

0 comments on commit 836a245

Please sign in to comment.