Skip to content

Commit 69af5f6

Browse files
committed
Added unique view counter.
1 parent c995699 commit 69af5f6

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

_plugins/index_controller.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def decorate_repository(repository)
7676
resource2hash(repository).merge!\
7777
'composer' => composer,
7878
'readme' => readme,
79+
'views' => download_unique_views(repository),
7980
'top_contributor' => download_top_contributor(repository),
8081
'emoji' => parse_emojis(repository.description)
8182
end
@@ -99,6 +100,13 @@ def download_readme_references(repository)
99100
print_repo_error repository, 'Readme not found.'
100101
end
101102

103+
def download_unique_views(repository)
104+
@client.views(
105+
repository.full_name,
106+
accept: Octokit::Preview::PREVIEW_TYPES[:traffic]
107+
)[:uniques]
108+
end
109+
102110
def download_top_contributor(repository)
103111
resource2hash repository.rels[:contributors].get.data.first
104112
end

index.haml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ layout: page
1414
%th Stars
1515
%th Version
1616
%th Monthly downloads
17+
%th
18+
%abbr(title='Unique views past 14 days') Views
1719
%th Build
1820
%th Coverage
1921
%th Style
20-
%th BDFL
22+
%th
23+
%abbr(title='Main contributor') BDFL
2124
{% for repo in set %}
2225
%tbody
2326
%tr
@@ -33,6 +36,8 @@ layout: page
3336
%td
3437
%a(href='https://packagist.org/packages/{{ repo.composer.name }}/stats')
3538
%img(src='https://poser.pugx.org/{{ repo.composer.name }}/d/monthly')
39+
%td
40+
{{ repo.views }}
3641
%td<
3742
{% if repo.readme['Build'] %}
3843
%a(href='{{ repo.readme['Build'].url }}')

public/css/stylesheet.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ form {
199199
padding: 20px;
200200
}
201201

202+
abbr {
203+
text-decoration: none;
204+
}
205+
202206
/*******************************************************************************
203207
Full-Width Styles
204208
*******************************************************************************/

0 commit comments

Comments
 (0)