summaryrefslogtreecommitdiff
path: root/client.rb
diff options
context:
space:
mode:
Diffstat (limited to 'client.rb')
-rw-r--r--client.rb40
1 files changed, 3 insertions, 37 deletions
diff --git a/client.rb b/client.rb
index 3b30861..7c58f85 100644
--- a/client.rb
+++ b/client.rb
@@ -122,7 +122,7 @@ post "/unfollow/*" do
end
post "/login" do
- session["client"] = true if params["secret"] == File.read(".pwd").chomp
+ session["client"] = true if OpenSSL::Digest::SHA256.base64digest(params["secret"]) == File.read(".digest").chomp
redirect to("/")
end
@@ -168,7 +168,7 @@ helpers do
:follow => follow,
:content => item['content'],
:attachment => item['attachment'],
- :indent => 2,
+ :indent => 0,
:replies => []
}
end.compact
@@ -183,7 +183,7 @@ helpers do
@threads << i
else
@items.select{|it| it[:id] == i[:parent] }.each do |it|
- i[:indent] = it[:indent] + 2
+ i[:indent] = it[:indent] + 4
it[:replies] << i
end
end
@@ -195,38 +195,4 @@ helpers do
erb :item
end
- def people
- File.read('cache/people.tsv').split("\n").collect {|l| l.chomp.split("\t")}
- end
-
- def mention actor
- person = people.select{|p| p[1] == actor}
- if person.empty?
- a = fetch(actor)
- return nil unless a
- mention = "#{a["preferredUsername"]}@#{URI(actor).host}"
- File.open('cache/people.tsv','a'){|f| f.puts "#{mention}\t#{actor}"}
- mention
- else
- person[0][0]
- end
- end
-
- def actor mention
- mention = mention.sub(/^@/, '').chomp
- actors = people.select{|p| p[0] == mention}
- if actors.empty?
- user, server = mention.split("@")
- a = fetch("https://#{server}/.well-known/webfinger?resource=acct:#{mention}", "application/jrd+json")
- return nil unless a
- actor = a["links"].select { |l|
- l["rel"] == "self"
- }[0]["href"]
- File.open('cache/people.tsv','a'){|f| f.puts "#{mention}\t#{actor}"}
- actor
- else
- actors[0][1]
- end
- end
-
end