Permalink
Browse files

fixed last character being truncated in comments

  • Loading branch information...
glebpopoff committed Jan 4, 2012
1 parent bea408f commit b8a8d956acd18fe21019a7cb6f67de598b667f82
Showing with 7 additions and 4 deletions.
  1. +1 −0 APIContent.py
  2. +3 −3 APIUtils.py
  3. +1 −1 main.py
  4. +2 −0 templates/index.html
View
@@ -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
@@ -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
@@ -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
@@ -106,6 +106,8 @@ <h1>Hacker News API (unofficial)</h2>
<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>

0 comments on commit b8a8d95

Please sign in to comment.