Skip to content

A tiny Deno server that accepts XML-RPC weblogUpdates.extendedPings, parses the submitted feed, and saves blogs, posts, and tags to a database

Notifications You must be signed in to change notification settings

jsit/pingsville-ping

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pingsville Ping

A tiny Deno server that:

  1. Accepts XML-RPC weblogUpdates.extendedPings,
  2. Parses the RSS/JSON feed, then
  3. Saves blogs, posts, and tags to a database

Set up

MongoDB

  1. Install MongoDB:

    brew install mongodb-community@7.0
    
  2. Run as a macOS service:

    brew services start mongodb-community@7.0
    

Deno

  1. Install Deno:

    brew install deno
    

Pingsville Ping

  1. Run server:

    deno task dev
    

Send test ping

Postman

Using Postman, you can send a POST request to localhost:1417 with the following raw XML in the body:

<?xml version="1.0"?>
<methodCall>
  <methodName>weblogUpdates.extendedPing</methodName>
  <params>
    <param>
      <value>
        <string>Example Blog</string>
      </value>
    </param>
    <param>
      <value>
        <string>https://blog.example.com/</string>
      </value>
    </param>
    <param>
      <value>
        <string>https://blog.example.com/feed/</string>
      </value>
    </param>
  </params>
</methodCall>

The Deno task should log the values to the console, and add an entry to the blogs database collection, if the URL is not a duplicate.

If a feed URL is provided, it will grab the feed XML/JSON and add all the entries to a database collection called blogPosts.

If these posts have categories or tags, those will be saved to a tags collection as well.

WordPress

You can also try this with real-world data from a local WordPress install (I recommend wp-now) by adding localhost:1417 to the list of Update Services in wp-admin/options-writing.php.

Viewing records

  1. Open mongo Shell (mongosh)
  2. List databases: show databases
  3. Switch to the Pingsville database: use pingsville
  4. Show collections: show collections

Blogs

  1. Show documents in blogs collection: db.blogs.find()
  2. Clear all blogs from the collection: db.blogs.deleteMany({})
  3. Count the number of blogs: db.blogs.countDocuments({})

Blog Posts

  1. Show documents in blogPosts collection: db.blogPosts.find()
  2. Clear all blogs from the collection: db.blogPosts.deleteMany({})
  3. Count the number of blogs: db.blogPosts.countDocuments({})
  4. Find all blog posts in reverse chronological order: db.blogPosts.find().sort({ pubDate: -1 })
  5. Find all blog posts with a particular tag: db.blogPosts.find({tags: ObjectId("XXXXXXXXXXXXXXXXXXXXXXXX")})
  6. Find all blog posts from a particular blog: db.blogPosts.find({"blog.id": ObjectId("XXXXXXXXXXXXXXXXXXXXXXXX")})

Tags

  1. Show documents in tags collection: db.tags.find()
  2. Clear all tags from the collection: db.tags.deleteMany({})
  3. Count the number of tags: db.tags.countDocuments({})

Cleanup

  1. Remove all instances of tag from all blog posts: db.blogPosts.updateMany({}, { $pull: { "tags": { id: ObjectId("XXXXXXXXXXXXXXXXXXXXXXXX") }}})

To Do

  • Normalize URLs (remove trailing slash, expand short URLs, etc.)
  • Look into using @foxglove/xmlrpc
  • Better error handling
  • Use GraphQL, to be database-agnostic
  • Prevent spamming?
  • A job queue?
  • Create Pingsville API, for querying data
  • Create Pingsville Web, for browsing content
  • Scrape feed data and store blog posts
  • Store tags
  • Normalize tags
  • Return something meaningful to the pinger (spec)

Resources

How you can help

Please help me! I don't know what I'm doing!!

You can reach me on Mastodon at @jsit@social.coop

License

Boy, I haven't really thought about this.

About

A tiny Deno server that accepts XML-RPC weblogUpdates.extendedPings, parses the submitted feed, and saves blogs, posts, and tags to a database

Topics

Resources

Stars

Watchers

Forks