Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show stars, created/updated at and enable sort/search of list #39

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bin/build-index-with-github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
COPY_REPO_PROPERTIES = [
:stargazers_count,
:watchers_count,
:forks
:forks,
:created_at
]

# Load the library data
Expand Down
5 changes: 5 additions & 0 deletions lib/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,8 @@ def strip_html(html)
def remove_links(text)
text.gsub(%r|(\w+)://|, '').gsub(/(\w+)\.(\w+)/, '\\1․\\2')
end

def gh_badge(repo, type, extra='')
key = repo.gsub(/.*github.com\/([^\/]+\/[^\/]+).*/,'\\1')
"<img src='https://flat.badgen.net/github/#{type}/#{key}/#{extra}' />"
end
4 changes: 4 additions & 0 deletions public/icons/download.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/icons/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/js/table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$(document).ready(function () {
$('table.datatable').DataTable()
});
4 changes: 4 additions & 0 deletions public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@
-webkit-box-shadow: none;
border-color: rgb(220, 228, 236)
}

.nowrap {
white-space: nowrap;
}
8 changes: 7 additions & 1 deletion views/layout.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.6/flatly/bootstrap.min.css" integrity="sha384-XYCjB+hFAjSbgf9yKUgbysEjaVLOXhCgATTEBpCqT1R3jvG5LGRAK5ZIyRbH5vpX" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/fontawesome.min.css" integrity="sha512-d0olNN35C6VLiulAobxYHZiXJmq+vl+BGIgAxQtD5+kqudro/xNMvv2yIHAciGHpExsIbKX3iLg+0B6d0k4+ZA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/brands.min.css" integrity="sha512-8RxmFOVaKQe/xtg6lbscU9DU0IRhURWEuiI0tXevv+lXbAHfkpamD4VKFQRto9WgfOJDwOZ74c/s9Yesv3VvIQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdn.datatables.net/v/bs/dt-1.13.8/datatables.min.css" crossorigin="anonymous">
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="/typeaheadjs.css">

Expand Down Expand Up @@ -130,11 +133,14 @@

<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/js/brands.min.js" integrity="sha512-giAmE8KpCT6HP3DEwIvW9LYVnDs79iIaKEYFTjH62EWoglWgdAJa1ahiLUfoc3NFaAeWM6E3VdQyH1Ob2dmwQw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/js/fontawesome.min.js" integrity="sha512-C8qHv0HOaf4yoA7ISuuCTrsPX8qjolYTZyoFRKNA9dFKnxgzIHnYTOJhXQIt6zwpIFzCrRzUBuVgtC4e5K1nhA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdn.datatables.net/v/bs/dt-1.13.8/datatables.min.js" crossorigin="anonymous"></script>
<!-- Library search -->
<script src="/js/typeahead.jquery.min.js"></script>
<script src="/js/fuse.min.js"></script>
<script src="/js/search.js"></script>
<script src="/js/table.js"></script>

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-81845219-1"></script>
Expand Down
57 changes: 51 additions & 6 deletions views/list.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,56 @@
<p><%== synopsis %></p>

<table class="table">
<% keys.sort.each do |key| %>
<% library = libraries[key] %>
<table class="table datatable" data-page-length="25">
<thead>
<tr>
<td><%== link_to(library[:name], :href => "/libraries/#{key}") %></td>
<td><%= library[:sentence] %></td>
<th>Name</th>
<th>Description</th>
<th data-type="num">Stars</th>
<th data-type="date">Updated&nbsp;at</th>
<th data-type="date">Created&nbsp;at</th>
<th data-orderable="false" data-searchable="false"></th>
</tr>
<% end %>
</thead>
<tbody>
<% keys.sort.each do |key| %>
<% library = libraries[key] %>
<tr>
<td><%== link_to(library[:name], :href => "/libraries/#{key}") %></td>
<td><%= library[:sentence] %></td>
<td>
<% if library[:stargazers_count] %>
<%== library[:stargazers_count] %>
<% else %>
<% end %>
</td>
<td class="nowrap">
<% if library[:release_date] %>
<%== Time.parse(library[:release_date]).strftime('%Y-%m-%d') %>
<% else %>
<% end %>
</td>
<td class="nowrap">
<% if library[:created_at] %>
<%== Time.parse(library[:created_at]).strftime('%Y-%m-%d') %>
<% else %>
<% end %>
</td>
<td class="nowrap">
<% if library[:repository] %>
<%== link_to('<i class="fa-brands fa-github"></i>', :href => library[:repository]) %>
<% else %>
<% end %>
<% if library[:website] %>
<%== link_to('<span class="glyphicon glyphicon-home"/>', :href => library[:website]) %>
<% else %>
<% end %>
<% if library[:versions] and library[:versions][0] %>
<%== link_to('<i class="glyphicon glyphicon-cloud-download"></i>', :href => library[:versions][0][:url]) %>
<% else %>
<% end %>
</td>

</tr>
<% end %>
</tbody>
</table>
11 changes: 11 additions & 0 deletions views/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
<dt>License</dt> <dd><%== link_to_license(library[:license]) %></dd>
<dt>Library Type</dt> <dd><%== pretty_list(library[:types]) %></dd>
<dt>Architectures</dt> <dd><%== pretty_list(library[:architectures]) %></dd>
<% if library[:github] %>
<dt></dt> <dd>
<%== gh_badge(library[:github], 'stars') %>
<%== gh_badge(library[:github], 'watchers') %>
<%== gh_badge(library[:github], 'release') %>
<%== gh_badge(library[:github], 'last-commit') %>
<%== gh_badge(library[:github], 'open-issues') %>
<%== gh_badge(library[:github], 'assets-dl') %>
<%== gh_badge(library[:github], 'label-issues', 'good-first-issue/open') %>
</dd>
<% end %>
</dl>

<p class="paragraph"><%= library[:paragraph] %></p>
Expand Down