summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--activitypub.rb20
-rw-r--r--public/style.css101
-rw-r--r--views/inbox.erb2
-rwxr-xr-xwatch7
5 files changed, 25 insertions, 106 deletions
diff --git a/.gitignore b/.gitignore
index c7e243e..d2522b8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
.pwd
inbox
public/*/
+*csv
diff --git a/activitypub.rb b/activitypub.rb
index 05ed6e0..ab42c4f 100644
--- a/activitypub.rb
+++ b/activitypub.rb
@@ -20,6 +20,10 @@ ACCOUNT = "#{USER}@#{SOCIAL_DOMAIN}"
SOCIAL_URL = "https://#{SOCIAL_DOMAIN}"
ACTOR = File.join(SOCIAL_URL, USER)
+#OpenSSL::SSL::SSLContext::DEFAULT_PARAMS = OpenSSL::SSL::SSLContext::DEFAULT_PARAMS.merge(
+ #options: OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options] + OpenSSL::SSL::OP_IGNORE_UNEXPECTED_EOF
+#).freeze
+
enable :sessions
set :session_secret, File.read(".secret").chomp
set :default_content_type, 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
@@ -34,7 +38,7 @@ end
post "/inbox" do # server-server
request.body.rewind # in case someone already read it
body = request.body.read
- p body
+ #p body
action = JSON.parse body
case action["type"]
@@ -55,7 +59,7 @@ post "/inbox" do # server-server
"id" => File.join(SOCIAL_URL + "#accepts", SecureRandom.uuid),
"type" => "Accept",
"actor" => ACTOR,
- "object" => action["object"] }
+ "object" => action }
send_signed accept, action["actor"]
when "Undo"
@@ -67,8 +71,8 @@ post "/inbox" do # server-server
end
end
- else
- p body
+ #else
+ #p body
end
end
@@ -77,7 +81,7 @@ post "/outbox" do # client-server
request.body.rewind # in case someone already read it
body = request.body.read
date = Time.now.strftime("%Y-%m-%dT%H:%M:%S")
- # TODO media attachments, hashtags
+ # TODO hashtags, replys
outbox_path = File.join("public/outbox", date + ".json")
object_path = File.join("public/objects", date + ".json")
create = {
@@ -126,7 +130,6 @@ post "/follow/*" do
protected!
mention = params['splat'][0]
actor = actor(mention)
- p actor
following_path = File.join("public", "following", mention + ".json")
follow = { "@context" => "https://www.w3.org/ns/activitystreams",
"id" => File.join(SOCIAL_URL, following_path),
@@ -171,7 +174,6 @@ end
get "/inbox", :provides => 'html' do
protected!
@inbox = Dir['./inbox/*'].sort
- p @inbox
erb :inbox
end
@@ -250,13 +252,11 @@ def send_signed object, url
request = Net::HTTP::Post.new(uri.request_uri, header)
request.body = body
+ p uri, body
http.request(request)
end
def inbox uri
- p "INBOX"
- p uri
- p get(uri)
URI(get(uri)["inbox"]).request_uri
end
diff --git a/public/style.css b/public/style.css
index 63fdb65..3e3b1e2 100644
--- a/public/style.css
+++ b/public/style.css
@@ -1,51 +1,10 @@
body {
- width: 100vw;
- margin: 0;
font-family: sans-serif;
+ font-size: 2em;
}
-nav {
- background: #000;
- color: #fff;
- padding: 0.75em 0 1em 0;
-}
-
-nav a {
- padding: 0 1em;
- text-decoration: none;
-}
-
-nav img {
- height: 2em;
- display: inline;
- vertical-align: bottom;
-}
-
-nav #logo img { height: 2em; }
-
-nav .current { color: #fff; }
-
-nav #menu { display:none; }
-
-nav a:hover { color: #fff; }
-
-@media screen and (max-width: 600px) {
- nav .item {
- display: none;
- padding-left: 1em;
- padding-top: 0.5em;
- }
-
- nav #menu {
- float: right;
- display: inline;
- font-size: 2em;
- }
-}
-
-.post { padding: 1em; }
-
-img, video {
+img,
+video {
max-width: 100%;
max-height: 80vh;
display: block;
@@ -53,56 +12,14 @@ img, video {
margin-right: auto;
}
-iframe {
- width: 100%;
- height: 90vh;
- border: none;
-}
-
-a {
- color: #888;
-}
-
-#image {
- padding-top: 2.5%;
- padding-bottom: 1%;
-}
-
-.cover {
- max-height: 50vh;
- margin-left: 0;
-}
-
-
-#controller {
- position: fixed;
- left: 0;
- bottom: 2.5%;
- width: 100%;
- text-align: center;
- padding: 0
-}
-
-.btn {
+form {
display: inline-block;
- cursor: pointer;
- color: #000;
- font-size: 2em;
- font-weight: bold;
- width: 4em;
}
-#prev, #next {
- cursor: pointer;
- position: absolute;
- color: lightgrey;
- font-weight: bold;
- font-size: 8em;
- transition: 0.5s ease;
- bottom: 6vh;
+button {
+ font-size: 1.5em;
}
-#prev { left: 1%; }
-#next { right: 1%; }
-#prev:hover, #next:hover { text-decoration: none; }
-#prev:active, #next:active { color: black; }
+a {
+ color: #888;
+} \ No newline at end of file
diff --git a/views/inbox.erb b/views/inbox.erb
index a3e3f83..0be5dd5 100644
--- a/views/inbox.erb
+++ b/views/inbox.erb
@@ -8,7 +8,7 @@
<% item = JSON.parse(File.read(file))
mention = mention(item['attributedTo'])
following_path = File.join('public', 'following', mention + '.json') %>
- <b><a href='<%= item['attributedTo'] %>', target='_blank'><%= mention %></a></b>&nbsp;<i><%= item['published'].sub('T', ' ') %></i>
+ <b><a href='<%= item['attributedTo'] %>', target='_blank'><%= mention %></a></b>&nbsp;
<% File.exists?(following_path) ? method = 'unfollow' : method = 'follow' %>
<form action='<%= File.join method, mention %>' method='post'>
<button><%= method.capitalize %></button>
diff --git a/watch b/watch
index 46f9a85..d8a276d 100755
--- a/watch
+++ b/watch
@@ -1,4 +1,5 @@
-#!/usr/bin/env fish
-while inotifywait -qqe modify activitypub.rb
+#!/bin/sh
+while inotifywait -qq -r ./ -e create,delete,modify; do
+ rsync -a --exclude='.git/' --exclude='watch' --filter=":- .gitignore" ./ /srv/social/
sudo systemctl restart social.service
-end
+done