summaryrefslogtreecommitdiff
path: root/social
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2023-05-29 17:17:26 +0200
committerpdp8 <pdp8@pdp8.info>2023-05-29 17:17:26 +0200
commit451757d05a6464194a741c54e879b338d6329bd6 (patch)
treeaea56cc7fb1c2c276ef5413b169e1b8172165557 /social
parentebe8adc1a65ff72da3fa9292d681f7da061696f0 (diff)
initial sinatra version
Diffstat (limited to 'social')
-rwxr-xr-xsocial49
1 files changed, 0 insertions, 49 deletions
diff --git a/social b/social
deleted file mode 100755
index db1685c..0000000
--- a/social
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/env ruby
-require 'net/http'
-require 'uri'
-
-USER = "pdp8"
-WWW_DOMAIN = "pdp8.info"
-SOCIAL_DOMAIN = "social.#{WWW_DOMAIN}"
-SOCIAL_URL = "https://#{SOCIAL_DOMAIN}"
-
-def post path, body
- uri = URI.parse(File.join SOCIAL_URL, path)
- http = Net::HTTP.new(uri.host, uri.port)
- http.use_ssl = true
- header = { 'Content-Type' => 'text/plain' }
- request = Net::HTTP::Post.new(uri.request_uri, header)
- usr = File.read(".usr").chomp
- pwd = File.read(".pwd").chomp
- request.basic_auth(usr, pwd)
- request.body = body
- response = http.request(request)
- # TODO return error if response.code > 400
- puts(response.body, response.code)
-end
-
-def get path
- uri = URI.parse(File.join SOCIAL_URL, path)
- http = Net::HTTP.new(uri.host, uri.port)
- http.use_ssl = true
- header = { 'Accept' => 'text/plain' }
- request = Net::HTTP::Get.new(uri.request_uri, header)
- usr = File.read(".usr").chomp
- pwd = File.read(".pwd").chomp
- request.basic_auth(usr, pwd)
- response = http.request(request)
- # TODO return error if response.code > 400
- puts(response.code, response.body)
-end
-
-# cmd = ARGV.shift
-case ARGV.shift
-when "post"
- post "outbox", File.read(ARGV[0])
-when "follow"
- post "follow", ARGV.join(" ")
-when "unfollow"
- post "unfollow", ARGV.join(" ")
-when "inbox"
- get "inbox"
-end