Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed last character being truncated in comments

  • Loading branch information...
commit b8a8d956acd18fe21019a7cb6f67de598b667f82 1 parent bea408f
@glebpopoff authored
View
1  APIContent.py
@@ -70,6 +70,7 @@ def getHackerNewsNestedComments(articleId, format='json', url='', referer='', re
apiURL = "%s/item?id=%s" % (AppConfig.hackerNewsURL, articleId)
apiURLBackup = "%s/item?id=%s" % (AppConfig.hackerNewsURLBackup, articleId)
id = '/nestedcomments/%s' % (articleId)
+ #cache data
cachedData = getCache(id,format)
if (cachedData):
return cachedData
View
6 APIUtils.py
@@ -24,7 +24,7 @@ def removeNonAscii(s): return "" . join(filter(lambda x: ord(x)<128, s))
#call urlfetch to get remote data
def fetchRemoteData(urlStr, deadline):
result = urlfetch.fetch(url=urlStr, deadline=deadline)
- if result.status_code == 200:
+ if result.status_code == 200 and result and result.content:
return result
else:
logging.error('fetchRemoteData: unable to get remote data: %s' % urlStr)
@@ -289,7 +289,7 @@ def parseCommentsContent(hnAPIUrl, hnAPIUrlBackup, apiURL, page='',format='json'
commentsString = re.sub("\r", "", commentsString)
if (len(commentsString) > 0):
- commentsString = Formatter.data(format, 'comment', escape(removeNonAscii(commentsString)))[:-1]
+ commentsString = Formatter.data(format, 'comment', escape(removeNonAscii(commentsString)))
else:
commentsString = "n/a "
else:
@@ -401,7 +401,7 @@ def parseNestedCommentsContent(hnAPIUrl, hnAPIUrlBackup, apiURL, page='',format=
commentsString = re.sub("\r", "", commentsString)
if (len(commentsString) > 0):
- commentsString = escape(removeNonAscii(commentsString))[:-1]
+ commentsString = escape(removeNonAscii(commentsString))
else:
commentsString = "n/a "
else:
View
2  main.py
@@ -21,7 +21,7 @@
class MainHandler(webapp.RequestHandler):
def get(self):
- template_values = {'last_updated': '12/23/11'}
+ template_values = {'last_updated': '01/04/12'}
path = os.path.join(os.path.dirname(__file__), 'templates')
path = os.path.join(path, 'index.html')
self.response.out.write(template.render(path, template_values))
View
2  templates/index.html
@@ -106,6 +106,8 @@
<div id="app-header">
<h3>Last updated: {{last_updated}}</h3>
<p>
+ <small>Update (01/04/12): Fixed the bug that was truncating last character in comments</small>
+ <br/>
<small>Update (12/23/11): Reached AppEngine Quotas (DataStore DELETE) so had to enable billing for the app and modify API calls to handle errors better. The API and app are fully functional now.</small>
<br/>
<small>Update (10/23/11): The API now supports nested comments as a new API call (/nestedcomments) (thanks to Suan Aik Yeo). The old comments API (/comments) has been deprecated.</small>
Please sign in to comment.
Something went wrong with that request. Please try again.