Permalink
Browse files

Use hub URLs from feeds

  • Loading branch information...
1 parent df3998c commit fac30b2601e6e7e7786880f9562932efcc630c54 @mjibson committed Dec 8, 2013
Showing with 17 additions and 4 deletions.
  1. +11 −0 admin.go
  2. +1 −0 main.go
  3. +0 −1 settings.go.dist
  4. +1 −1 tasks.go
  5. +3 −1 templates/admin-feed.html
  6. +1 −1 types.go
View
@@ -126,6 +126,17 @@ func AdminUpdateFeed(c mpg.Context, w http.ResponseWriter, r *http.Request) {
}
}
+func AdminSubHub(c mpg.Context, w http.ResponseWriter, r *http.Request) {
+ gn := goon.FromContext(c)
+ f := Feed{Url: r.FormValue("f")}
+ if err := gn.Get(&f); err != nil {
+ serveError(w, err)
+ return
+ }
+ f.Subscribe(c)
+ fmt.Fprintf(w, "subscribed")
+}
+
func AdminDateFormats(c mpg.Context, w http.ResponseWriter, r *http.Request) {
type df struct {
URL, Format string
View
@@ -80,6 +80,7 @@ func init() {
router.Handle("/admin/user", mpg.NewHandler(AdminUser)).Name("admin-user")
router.Handle("/date-formats", mpg.NewHandler(AdminDateFormats)).Name("admin-date-formats")
router.Handle("/admin/feed", mpg.NewHandler(AdminFeed)).Name("admin-feed")
+ router.Handle("/admin/subhub", mpg.NewHandler(AdminSubHub)).Name("admin-subhub-feed")
router.Handle("/admin/stats", mpg.NewHandler(AdminStats)).Name("admin-stats")
router.Handle("/admin/update-feed", mpg.NewHandler(AdminUpdateFeed)).Name("admin-update-feed")
router.Handle("/user/charge", mpg.NewHandler(Charge)).Name("charge")
View
@@ -13,7 +13,6 @@ var (
const (
GOOGLE_ANALYTICS_ID = ""
GOOGLE_ANALYTICS_HOST = ""
- PUBSUBHUBBUB_HUB = "http://pubsubhubbub.appspot.com"
PUBSUBHUBBUB_HOST = "" // e.g., "www.goread.io"
STRIPE_KEY = ""
STRIPE_SECRET = ""
View
@@ -211,7 +211,7 @@ func SubscribeFeed(c mpg.Context, w http.ResponseWriter, r *http.Request) {
fu, _ := url.Parse(f.Url)
fu.Fragment = ""
u.Add("hub.topic", fu.String())
- req, err := http.NewRequest("POST", PUBSUBHUBBUB_HUB, strings.NewReader(u.Encode()))
+ req, err := http.NewRequest("POST", f.Hub, strings.NewReader(u.Encode()))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
cl := &http.Client{
Transport: &urlfetch.Transport{
@@ -2,6 +2,7 @@
<body>
<a href="{{url "admin-update-feed"}}?f={{.Feed.Url}}">update</a>
+<a href="{{url "admin-subhub-feed"}}?f={{.Feed.Url}}">pubsub subscribe</a>
<table>
<tr><td>url</td><td>{{.Feed.Url}}</td></tr>
@@ -20,7 +21,8 @@
<tr><td>subscribed</td><td>{{.Feed.Subscribed}}</td><td>{{since .Feed.Subscribed}}</td></tr>
<tr><td>last view</td><td>{{.Feed.LastViewed}}</td><td>{{since .Feed.LastViewed}}</td></tr>
<tr><td>average</td><td>{{.Feed.Average}}</td></tr>
- <tr><td><a href="https://pubsubhubbub.appspot.com/subscription-details?hub.callback={{.Feed.PubSubURL}}&hub.topic={{.Feed.Url}}">pubsub</a></td></tr>
+ <tr><td>is subbed</td><td>{{.Feed.IsSubscribed}}</td></tr>
+ <tr><td><a href="{{.Feed.Hub}}/subscription-details?hub.callback={{.Feed.PubSubURL}}&hub.topic={{.Feed.Url}}">pubsub</a></td></tr>
</table>
logs:
View
@@ -157,7 +157,7 @@ func (f *Feed) Subscribe(c appengine.Context) {
}
func (f *Feed) IsSubscribed() bool {
- return !ENABLE_PUBSUBHUBBUB || time.Now().Before(f.Subscribed)
+ return !ENABLE_PUBSUBHUBBUB || f.Hub == "" || time.Now().Before(f.Subscribed)
}
func (f *Feed) PubSubURL() string {

0 comments on commit fac30b2

Please sign in to comment.