kopia lustrzana https://github.com/snarfed/bridgy-fed
add /log handler, link to it from /responses
reuses LogHandler newly moved from bridgy to webutil in snarfed/webutil@a49b3af4d1pull/27/head
rodzic
22ca3e64a6
commit
07c650b9e1
3
app.yaml
3
app.yaml
|
@ -1,6 +1,7 @@
|
|||
# https://cloud.google.com/appengine/docs/standard/python/config/appref
|
||||
|
||||
# application: bridgy-federated
|
||||
# version: 1
|
||||
runtime: python27
|
||||
threadsafe: yes
|
||||
api_version: 1
|
||||
|
@ -62,7 +63,7 @@ handlers:
|
|||
script: render.app
|
||||
secure: always
|
||||
|
||||
- url: /responses
|
||||
- url: /(log|responses)
|
||||
script: logs.app
|
||||
secure: always
|
||||
|
||||
|
|
23
logs.py
23
logs.py
|
@ -1,20 +1,22 @@
|
|||
"""Handlers and utilities for exposing app logs to users.
|
||||
"""
|
||||
import cgi
|
||||
"""Render recent responses and logs."""
|
||||
import calendar
|
||||
import datetime
|
||||
import logging
|
||||
import re
|
||||
import urllib
|
||||
|
||||
import appengine_config
|
||||
from google.appengine.api import logservice
|
||||
from google.appengine.ext import ndb
|
||||
from oauth_dropins.webutil.handlers import TemplateHandler
|
||||
|
||||
from oauth_dropins.webutil import util
|
||||
from oauth_dropins.webutil.handlers import TemplateHandler
|
||||
from oauth_dropins.webutil import logs
|
||||
import webapp2
|
||||
|
||||
from models import Response
|
||||
|
||||
VERSION_1_DEPLOYED = datetime.datetime(2017, 10, 26, 16, 0)
|
||||
|
||||
|
||||
class LogHandler(logs.LogHandler):
|
||||
VERSION_IDS = ['1']
|
||||
|
||||
|
||||
class ResponsesHandler(TemplateHandler):
|
||||
"""Renders recent Responses, with links to logs."""
|
||||
|
@ -28,6 +30,8 @@ class ResponsesHandler(TemplateHandler):
|
|||
for r in responses:
|
||||
r.source, r.target = [util.pretty_link(url)
|
||||
for url in r.key.id().split(' ')]
|
||||
if r.updated >= VERSION_1_DEPLOYED:
|
||||
r.start_time = calendar.timegm(r.updated.timetuple())
|
||||
|
||||
return {
|
||||
'responses': responses,
|
||||
|
@ -35,5 +39,6 @@ class ResponsesHandler(TemplateHandler):
|
|||
|
||||
|
||||
app = webapp2.WSGIApplication([
|
||||
('/log', LogHandler),
|
||||
('/responses', ResponsesHandler),
|
||||
], debug=appengine_config.DEBUG)
|
||||
|
|
|
@ -15,14 +15,21 @@
|
|||
<h3>Recent requests we've attempted to federate.</h3>
|
||||
|
||||
<table>
|
||||
<tr><th>Source</th> <th>Target</th> <th>Protocol</th> <th>Status</th> <th>Log</th></tr>
|
||||
<tr><th>Source</th> <th>Target</th> <th>Protocol</th> <th>Status</th> <th>Time (click for log)</th></tr>
|
||||
{% for r in responses %}
|
||||
<tr>
|
||||
<td>{{ r.source|safe }}</td>
|
||||
<td>{{ r.target|safe }}</td>
|
||||
<td>{{ r.protocol }}</td>
|
||||
<td>{{ r.status }}</td>
|
||||
<td><a href="">{{ r.updated.replace(microsecond=0) }}</a></td>
|
||||
<td>
|
||||
{# TODO: support inbound too #}
|
||||
{% if r.direction == 'out' and r.start_time %}
|
||||
<a href="/log?{{ {'key': r.key.id(), 'start_time': r.start_time}|urlencode }}">
|
||||
{% endif %}
|
||||
{{ r.updated.replace(microsecond=0) }}
|
||||
{% if r.direction == 'out' %}</a>{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
|
|
@ -41,6 +41,7 @@ class WebmentionHandler(webapp2.RequestHandler):
|
|||
logging.info('Params: %s', self.request.params.items())
|
||||
source = util.get_required_param(self, 'source')
|
||||
target = util.get_required_param(self, 'target')
|
||||
logging.info('source target: %s %s', source, target)
|
||||
|
||||
try:
|
||||
msg = 'Bridgy Fed: new webmention from %s' % source
|
||||
|
|
Ładowanie…
Reference in New Issue