Class: Jekyll::HackclubPFP

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/tags/profile-pic.rb

Instance Method Summary collapse

Constructor Details

#initialize(tagName, content, tokens) ⇒ HackclubPFP

Returns a new instance of HackclubPFP.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/tags/profile-pic.rb', line 6

def initialize(tagName, content, tokens)
    super
    if content.strip =~ /^(U\w+)(?:@(.+))?$/
        id = Regexp.last_match(1)
        data = HackclubRequest.raw_user(id)
        @resolution = Regexp.last_match(2) || "original"

        @img_url = HackclubRequest.get_pfp_url(id, @resolution)
    else
        raise ArgumentError, "Invalid profilepic tag format: #{content}"
    end
end

Instance Method Details

#render(context) ⇒ Object



19
20
21
# File 'lib/tags/profile-pic.rb', line 19

def render(context)
    %Q{<img src="#{@img_url}" title="Slack profile picture" alt="Slack profile picture" class="hackclub-pfp res-#{@resolution}">}
end