There be a website
This commit is contained in:
parent
64fb080e96
commit
af0907c7c3
65 changed files with 708 additions and 14 deletions
5
app/components/wah_component.html.erb
Normal file
5
app/components/wah_component.html.erb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<div class="wah">
|
||||
<h3>Random Wah!</h3>
|
||||
<%= image_tag @wah_url, alt: "Random image featuring a red panda" %>
|
||||
<p>Image "stolen" from <a href="https://tinyfox.dev/">tinyfox.dev</a></p>
|
||||
</div>
|
||||
21
app/components/wah_component.rb
Normal file
21
app/components/wah_component.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
require "net/http"
|
||||
require "json"
|
||||
|
||||
class WahComponent < ViewComponent::Base
|
||||
def initialize(legacy:)
|
||||
if legacy then
|
||||
else
|
||||
uri = URI.parse('https://api.tinyfox.dev/img.json?animal=wah')
|
||||
req = Net::HTTP::Get.new(uri.to_s)
|
||||
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) {|http|
|
||||
http.request(req)
|
||||
}
|
||||
data = JSON.parse(res.body)
|
||||
url = "https://tinyfox.dev" + data["loc"]
|
||||
|
||||
@wah_url = url
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue