From 22ca3e64a660220f61f812a8dc16094958ba68ba Mon Sep 17 00:00:00 2001
From: Ryan Barrett
Date: Wed, 25 Oct 2017 21:32:59 -0700
Subject: [PATCH] add /responses page with links to raw logs
log handler itself is next.
---
app.yaml | 4 ++++
logs.py | 39 +++++++++++++++++++++++++++++++++++++++
requirements.txt | 1 +
static/index.html | 8 ++++++++
static/style.css | 7 +++++++
templates/responses.html | 32 ++++++++++++++++++++++++++++++++
6 files changed, 91 insertions(+)
create mode 100644 logs.py
create mode 100644 templates/responses.html
diff --git a/app.yaml b/app.yaml
index 6d7b238..010ae5e 100644
--- a/app.yaml
+++ b/app.yaml
@@ -62,6 +62,10 @@ handlers:
script: render.app
secure: always
+- url: /responses
+ script: logs.app
+ secure: always
+
- url: /wm/.+
script: add_webmention.app
secure: always
diff --git a/logs.py b/logs.py
new file mode 100644
index 0000000..9e3de5a
--- /dev/null
+++ b/logs.py
@@ -0,0 +1,39 @@
+"""Handlers and utilities for exposing app logs to users.
+"""
+import cgi
+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
+import webapp2
+
+from models import Response
+
+
+class ResponsesHandler(TemplateHandler):
+ """Renders recent Responses, with links to logs."""
+
+ def template_file(self):
+ return 'templates/responses.html'
+
+ def template_vars(self):
+ responses = Response.query().order(-Response.updated).fetch(20)
+
+ for r in responses:
+ r.source, r.target = [util.pretty_link(url)
+ for url in r.key.id().split(' ')]
+
+ return {
+ 'responses': responses,
+ }
+
+
+app = webapp2.WSGIApplication([
+ ('/responses', ResponsesHandler),
+], debug=appengine_config.DEBUG)
diff --git a/requirements.txt b/requirements.txt
index 1122539..94662ac 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,6 +4,7 @@ bs4
feedparser
granary>=1.8
httpsig
+jinja2
mf2py>=1.0.4
mf2util>=0.5.0
mock
diff --git a/static/index.html b/static/index.html
index 2ca7a30..da53093 100644
--- a/static/index.html
+++ b/static/index.html
@@ -50,6 +50,7 @@ and the rest of the fediverse<
Which sites are supported?
How do I set it up?
How do I use it?
+I tried it, and it didn't work!
How much does it cost?
Who are you? Why did you make this?
What do you do with my data?
@@ -204,6 +205,13 @@ For replies, the source will usually be the permalink on the social network itse
+I tried it, and it didn't work!
+
+If you sent a webmention, check the HTTP response code and body. It will usually describe the error.
+If you got an HTTP 204 from an attempt to federate a response to Mastodon, that means Mastodon accepted the response. If it doesn't show up, that's a known inconsistency right now. We're actively working with them to debug these cases.
+You can also see recent Bridgy Fed requests here , including raw logs. Warning: not for the faint of heart!
+
+
How much does it cost?
Nothing! Bridgy Fed is small, and it doesn't cost much to run. We don't need donations, promise.
diff --git a/static/style.css b/static/style.css
index c40142d..20c2e44 100644
--- a/static/style.css
+++ b/static/style.css
@@ -157,3 +157,10 @@ pre .keyword, code.keyword {
pre .value, code.value {
color: chocolate;
}
+
+td, th {
+ padding-left: .4em;
+ padding-right: .4em;
+ padding-top: .2em;
+ padding-bottom: .2em;
+}
diff --git a/templates/responses.html b/templates/responses.html
new file mode 100644
index 0000000..ba55f66
--- /dev/null
+++ b/templates/responses.html
@@ -0,0 +1,32 @@
+
+
+
+
+Bridgy Fed: Logs
+
+
+
+
+
+
+
+
+Bridgy Fed: Logs
+Recent requests we've attempted to federate.
+
+
+Source Target Protocol Status Log
+{% for r in responses %}
+
+ {{ r.source|safe }}
+ {{ r.target|safe }}
+ {{ r.protocol }}
+ {{ r.status }}
+ {{ r.updated.replace(microsecond=0) }}
+
+{% endfor %}
+
+
+
+
+