Skip to content
Browse files

bot and minor fix

  • Loading branch information...
1 parent f9d1241 commit ef4843d50adbda6cad37d296d7900a369039c5ea @systempuntoout committed
View
12 app/core/stackprinterdownloader.py
@@ -13,6 +13,8 @@
import app.utility.worker as worker
import app.db.question as dbquestion
+VOTES_ENTRY_LEVEL = 10
+
deferred.deferred._TASKQUEUE_HEADERS['X-AppEngine-FailFast'] = 'True'
class Post(object):
@@ -61,7 +63,8 @@ def get_question(self, question_id):
question = results["items"]
if len(question) > 0 and question[0].has_key('title'):
try:
- deferred.defer(worker.deferred_store_question_to_cache, question_id, self.service, question[0])
+ if int(question[0]['up_vote_count'])-int(question[0]['down_vote_count']) > VOTES_ENTRY_LEVEL :
+ deferred.defer(worker.deferred_store_question_to_cache, question_id, self.service, question[0])
except:
logging.info("%s - defer error trying to store question_id : %s" % (self.service, question_id))
return question[0]
@@ -148,7 +151,7 @@ def get_answers(self, question_id):
page = page +1
return answers"""
- def get_answers(self, question_id):
+ def get_answers(self, question_id, persist = True):
answers_chunk_dict = {}
answers = []
page = 1
@@ -186,7 +189,8 @@ def create_callback(rpc, page):
try:
#cache it to db (does not work for payload bigger than 1MByte)
- deferred.defer(worker.deferred_store_answers_to_cache, question_id, self.service, answers)
+ if persist:
+ deferred.defer(worker.deferred_store_answers_to_cache, question_id, self.service, answers)
except:
logging.info("%s - defer error trying to store answers of question_id : %s" % (self.service, question_id))
@@ -278,7 +282,7 @@ def get_post(self, question_id, bypass_cache = False):
try:
question = self.get_question(question_id)
if question:
- post = Post(question, self.get_answers(question_id))
+ post = Post(question, self.get_answers(question_id, int(question['up_vote_count'])-int(question['down_vote_count']) > VOTES_ENTRY_LEVEL))
else: #StackPrinter loves the legendary deleted questions
post = Post(dbquestion.get_question(question_id, self.service),
dbquestion.get_answers(question_id, self.service))
View
3 app/static/docs/robots.txt
@@ -1,5 +1,8 @@
User-Agent: *
Disallow: /admin
Disallow: /myse
+Disallow: /topprinted
+Disallow: /topvoted
+Disallow: /favorites
Sitemap: http://www.stackprinter.com/sitemap_index.xml
Sitemap: http://www.stackprinter.com/sitemap.xml
View
9 app/static/docs/sitemap.xml
@@ -10,15 +10,6 @@
<loc>http://www.stackprinter.com/</loc>
</url>
<url>
- <loc>http://www.stackprinter.com/favorites</loc>
-</url>
-<url>
- <loc>http://www.stackprinter.com/topvoted</loc>
-</url>
-<url>
- <loc>http://www.stackprinter.com/topprinted</loc>
-</url>
-<url>
<loc>http://www.stackprinter.com/deleted</loc>
</url>
<url>
View
11 app/views/__init__.py
@@ -211,11 +211,9 @@ def __template__ (service, post, pretty_links, printer, link_to_home, pretty_pri
yield '', join_(' <script type="text/javascript" src="/javascripts/jquery-1.4.2.min.js"></script>\n')
yield '', join_(' <script type="text/javascript" src="/javascripts/main.js"></script>\n')
if pretty_print and 'Prettify' in supported_services.info[service].get('markdown_extensions',''):
- yield '', join_(' ', '<script type="text/javascript" src="/javascripts/prettify/prettify.js"></script>\n')
- yield '', join_(' ', '<link rel="stylesheet" href="/stylesheets/prettify.css"> \n')
- yield '', join_(' <script type="text/javascript">\n')
- yield '', join_(' jQuery(document).ready(function(){StyleCode();});\n')
- yield '', join_(' </script>\n')
+ yield '', join_(' ', ' <script type="text/javascript" src="/javascripts/prettify/prettify.js"></script>\n')
+ yield '', join_(' ', ' <link rel="stylesheet" href="/stylesheets/prettify.css"> \n')
+ yield '', join_(' ', ' <script type="text/javascript">jQuery(document).ready(function(){StyleCode();});</script>\n')
if 'MathJax' in supported_services.info[service].get('markdown_extensions',''):
yield '', join_(' ', '<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">\n')
yield '', join_(' ', '\n')
@@ -806,8 +804,9 @@ def __template__ (counter):
yield '', join_(' <li><a href="http://userscripts.org/scripts/show/77298" >StackPrinter GreaseMonkey script</a></li>\n')
yield '', join_(' <li><a href="javascript:(function(){var re = new RegExp(\'^http://(.*?)\\.com/questions/([0-9]+)/\');var group = re.exec(window.location.href);if (group!=null){var service = group[1];var questionid=group[2];window.open(\'http://www.stackprinter.com/export?format=HTML&service=\'+service+\'&question=\'+questionid)}else{alert(\'Attention: question id not found!\')}})()">StackPrinter Bookmarklet</a></li> \n')
yield '', join_(' <li><a href="http://stackapps.com/questions/179/stackprinter-the-stack-exchange-printer-suite">Feedback</a>\n')
+ yield '', join_(' <li><a href="https://twitter.com/systempuntoout">@Systempuntoout</a> \n')
yield '', join_(' <li>Questions printed so far: <b>', escape_((counter), True), '</b> </li>\n')
- yield '', join_(' <li>Sponsor: <a class="nolines" href="http://www.calcolobolloauto.net">Calcolo bollo auto</a></li>\n')
+ yield '', join_(' <li>Sponsor: <a class="nolines" href="http://www.calcolobolloauto.net">Calcolo del Bollo Auto</a></li>\n')
yield '', join_(' </ul>\n')
yield '', join_(' </div>\n')
yield '', join_(' <div id="appengine_logo">\n')
View
8 app/views/export.html
@@ -10,11 +10,9 @@
<script type="text/javascript" src="/javascripts/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/javascripts/main.js"></script>
$if pretty_print and 'Prettify' in supported_services.info[service].get('markdown_extensions',''):
- <script type="text/javascript" src="/javascripts/prettify/prettify.js"></script>
- <link rel="stylesheet" href="/stylesheets/prettify.css">
- <script type="text/javascript">
- jQuery(document).ready(function(){StyleCode();});
- </script>
+ <script type="text/javascript" src="/javascripts/prettify/prettify.js"></script>
+ <link rel="stylesheet" href="/stylesheets/prettify.css">
+ <script type="text/javascript">jQuery(document).ready(function(){StyleCode();});</script>
$if 'MathJax' in supported_services.info[service].get('markdown_extensions',''):
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
View
3 app/views/index.html
@@ -106,8 +106,9 @@
<li><a href="http://userscripts.org/scripts/show/77298" >StackPrinter GreaseMonkey script</a></li>
<li><a href="javascript:(function(){var re = new RegExp('^http://(.*?)\.com/questions/([0-9]+)/');var group = re.exec(window.location.href);if (group!=null){var service = group[1];var questionid=group[2];window.open('http://www.stackprinter.com/export?format=HTML&service='+service+'&question='+questionid)}else{alert('Attention: question id not found!')}})()">StackPrinter Bookmarklet</a></li>
<li><a href="http://stackapps.com/questions/179/stackprinter-the-stack-exchange-printer-suite">Feedback</a>
+ <li><a href="https://twitter.com/systempuntoout">@Systempuntoout</a>
<li>Questions printed so far: <b>$(counter)</b> </li>
- <li>Sponsor: <a class="nolines" href="http://www.calcolobolloauto.net">Calcolo bollo auto</a></li>
+ <li>Sponsor: <a class="nolines" href="http://www.calcolobolloauto.net">Calcolo del Bollo Auto</a></li>
</ul>
</div>
<div id="appengine_logo">

0 comments on commit ef4843d

Please sign in to comment.
Something went wrong with that request. Please try again.