Skip to content

Commit b13fd23

Browse files
committed
Added nokogiri
1 parent ebf170c commit b13fd23

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

app/controllers/application_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ class ApplicationController < ActionController::Base
22
# Prevent CSRF attacks by raising an exception.
33
# For APIs, you may want to use :null_session instead.
44
protect_from_forgery with: :exception
5+
6+
require 'nokogiri'
7+
require 'open-uri'
58
end
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
class WelcomeController < ApplicationController
22

33
def index
4-
4+
url = "https://github.com/bad6e"
5+
data = Nokogiri::HTML(open(url))
6+
@name = data.at_css(".vcard-fullname").text.strip
7+
@count = data.at_css(".contrib-number").text.strip
58
end
69
end

app/views/welcome/index.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<div class="row">
7070
<div class="col-lg-12 text-center">
7171
<h3>Leaderboard</h3>
72+
<h4><%= @name %>: <%= @count %></h4>
7273
</div>
7374
</div>
7475
<!-- /.row -->

0 commit comments

Comments
 (0)