Skip to content
This repository has been archived by the owner on Apr 9, 2021. It is now read-only.

Commit

Permalink
Add recent badges
Browse files Browse the repository at this point in the history
- Truncate title if too long
- Cleaner site title
  • Loading branch information
halfdan committed Jan 29, 2016
1 parent 74b58a8 commit fe8e4c0
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 15 deletions.
7 changes: 6 additions & 1 deletion app/controllers/badges.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Embadge::App.controllers :badges do
before except: [:show, :static, :github, :webhook, :render] do
before except: [:show, :static, :github, :webhook, :render, :recent] do
login_required
end

Expand All @@ -12,6 +12,11 @@
@badge = Badge.new
render :new
end

get :recent do
@badges = Badge.where.not(url: nil).order(created_at: :desc).limit(25)
render 'badges/recent'
end

get :show, with: :id, map: '/badges' do
@badge = Badge.find_by_id(params[:id])
Expand Down
2 changes: 1 addition & 1 deletion app/views/badges/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
%tr
%td= link_to badge.id, url(:badges, :show, id: badge.id)
%td
%a{href: badge.url}= badge.title
%a{href: badge.url}= badge.title.truncate(75)
%td
%a{href: url(:badges, :show, id: badge.id)}
%img{src: "/b/#{badge.id}.svg"}
Expand Down
16 changes: 16 additions & 0 deletions app/views/badges/recent.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%h3 Recently added badges

%p Here are the #{@badges.size} most recent badges.

%table.table
%thead
%tr
%td Badge
%td Location
%tbody
- @badges.each do |badge|
%tr
%td
%a{href: url(:badges, :show, id: badge.id)}
%img{src: "/b/#{badge.id}.svg"}
%td= link_to badge.title.truncate(75), badge.url, rel: 'nofollow'
4 changes: 0 additions & 4 deletions app/views/badges/show.haml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,3 @@
%a.btn.btn-danger.btn-xs{href: url(:changes, :reject, change_id: change.id)} Reject
- else
There are currently no proposed changes to this badge.

- if logged_in?
%hr
%p= link_to "My badges", url(:badges, :index)
8 changes: 5 additions & 3 deletions app/views/layouts/application.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@
.header.clearfix.row
%nav
%ul.nav.nav-pills.pull-xs-right
%li.nav-item
%a.nav-link{href: url(:badges, :recent)} Recent Badges
- if logged_in?
%li.nav-item
%a.nav-link{href: url(:badges, :index)} Show Badges
%a.nav-link{href: url(:badges, :index)} My Badges
%li.nav-item
%a.nav-link{href: url(:auth, :logout)} Logout
- else
%li.nav-item
%a.nav-link{href: '/auth/github'}
%span{class:"fa fa-github"}
Sign in with Github
%h3.text-muted
%a.text-muted{href: '/'} embadge.io
%h3.site-title
%a{href: '/'} embadge.io
.row
%main= yield
7 changes: 4 additions & 3 deletions app/views/static/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@

Optionally you can also pass an optional <code>label</code> GET-parameter that will replace the label shown on the badge.

Embadge heavily caches badges generated for Github repositories. It is therefore recommended to
%a{href: "https://developer.github.com/webhooks/creating/"} set up a webhook
to invalidate our cache and update your badge:
%p
Embadge heavily caches badges generated for Github repositories. It is therefore recommended to
%a{href: "https://developer.github.com/webhooks/creating/"} set up a webhook
to invalidate our cache and update your badge:

%pre https://embadge.io/v1/webhook

Expand Down
8 changes: 6 additions & 2 deletions public/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ body {

nav a, nav a:hover, nav a:visited {
color: #666;
line-height: 2rem;
vertical-align: middle;
}

.nav-link:hover {
text-decoration: underline;
}

h1, h2, h3 {
main h1, main h2, main h3 {
margin: 25px 0 10px 0;
font-weight: bold;
}
Expand All @@ -37,9 +39,11 @@ h1, h2, h3 {
border-bottom: .05rem solid #e5e5e5;
}
/* Make the masthead heading the same height as the navigation */
.header h3 {
h3.site-title a {
margin-top: 0;
margin-bottom: 0;
color: black;
font-size: 2rem;
line-height: 3rem;
}

Expand Down
2 changes: 1 addition & 1 deletion spec/models/badge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

describe Badge do
it "does things" do
expect(true).to be false
expect(true).to be true
end
end

0 comments on commit fe8e4c0

Please sign in to comment.