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

Commit

Permalink
Static controllers, some templates and badge.js + main.css
Browse files Browse the repository at this point in the history
  • Loading branch information
halfdan committed Jan 23, 2016
1 parent 3f4c69a commit c48f2df
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ gem 'rake'
# Component requirements
gem 'activerecord', '>= 3.1', :require => 'active_record'
gem 'sqlite3'

gem 'haml'
# Test requirements

# Padrino Stable Gem
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ GEM
arel (6.0.3)
builder (3.2.2)
enumerable-lazy (0.0.1)
haml (4.0.7)
tilt
i18n (0.7.0)
json (1.8.3)
mail (2.6.4.rc2)
Expand Down Expand Up @@ -80,6 +82,7 @@ PLATFORMS

DEPENDENCIES
activerecord (>= 3.1)
haml
padrino (= 0.13.1)
rake
sqlite3
23 changes: 23 additions & 0 deletions app/controllers/badge.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Embadge::App.controllers :badge do

# get :index, :map => '/foo/bar' do
# session[:foo] = 'bar'
# render 'index'
# end

# get :sample, :map => '/sample/url', :provides => [:any, :js] do
# case content_type
# when :js then ...
# else ...
# end

# get :foo, :with => :id do
# "Maps to url '/foo/#{params[:id]}'"
# end

# get '/example' do
# 'Hello world!'
# end


end
8 changes: 8 additions & 0 deletions app/controllers/static.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Embadge::App.controllers :static do

get :index, map: '/' do
render :index
end


end
13 changes: 13 additions & 0 deletions app/helpers/badge_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Helper methods defined here can be accessed in any controller or view in the application

module Embadge
class App
module BadgeHelper
# def simple_helper_method
# ...
# end
end

helpers BadgeHelper
end
end
13 changes: 13 additions & 0 deletions app/helpers/static_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Helper methods defined here can be accessed in any controller or view in the application

module Embadge
class App
module StaticHelper
# def simple_helper_method
# ...
# end
end

helpers StaticHelper
end
end
12 changes: 12 additions & 0 deletions app/views/layouts/application.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
!!!
%html
%head
%title embadge.io
%link{:href => "//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700", :rel => "stylesheet", :type => "text/css"}/
%link{:href => "/css/main.css", :rel => "stylesheet", :type => "text/css"}/
%body
%a{:href => "https://github.com/halfdan/embadge.io"}
%img{:alt => "Fork me on GitHub", :src => "https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png", :style => "position: absolute; top: 0; right: 0; border: 0;"}/
#content
%h1 embadge.io
%main= yield
74 changes: 74 additions & 0 deletions app/views/static/index.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
%p
embadge.io is a simple Ember.js badge generator service.
It provides a simple to use API.
It's inspired by Matthew Beale's 
%a{:href => "https://github.com/mixonic/ember-community-versions"} Ember Community Versions
and is open-sourced 
%a{:href => "https://github.com/halfdan/embadge.io"} on Github
%h2#examples Examples
%ul
%li
With start version:
%br/
%a{:href => "//embadge.io/v1/badge.svg?start=1.13.0"}
%img{:src => "//embadge.io/v1/badge.svg?start=1.13.0"}/
%li
With start and end version:
%br/
%a{:href => "//embadge.io/v1/badge.svg?start=1.13.0&end=2.0.0"}
%img{:src => "//embadge.io/v1/badge.svg?start=1.13.0&end=2.0.0"}/
%li
With range:
%br/
%a{:href => "//embadge.io/v1/badge.svg?range=^2.3.0"}
%img{:src => "//embadge.io/v1/badge.svg?range=^2.3.0"}/
%li
With custom label:
%br/
%a{:href => "//embadge.io/v1/badge.svg?label=ember-cli&start=1.13.13"}
%img{:src => "//embadge.io/v1/badge.svg?label=ember-cli&start=1.13.13"}/
%li
With custom label and range:
%br/
%a{:href => "//embadge.io/v1/badge.svg?label=ember-data&range=^2.3.0"}
%img{:src => "//embadge.io/v1/badge.svg?label=ember-data&range=^2.3.0"}/
%h2#usage Usage
%p The embadge.io API supports four different parameters.
%ul
%li
%pre> label
Used to define the text label shown on the badge (default: 'ember-versions')
%li
%pre> start
Valid semver string noting the earliest supported version.
%li
%pre> end
(Optional) Valid semver string noting the last supported version.
%li
%pre> range
(Optional) Valid semver range (e.g. "^2.3.0") noting a supported range of versions. If given,
%code start
and
%code end
will be ignored.
%p
The API supports HTTPS and is accessed from is
%code https://embadge.io/v1/badge.svg
%h3#browser Browser
%p In order to easily add embadge.io to your website you can include the following script in the body:
%code
%pre <script src="//embadge.io/v1/badge.js" type="text/javascript"></script>
%p
This will search your page for
%code span
elements with the
%code embadge
class and use data attributes to generate the image URL.
%code
%pre <span class="embadge" data-start="2.3.0"><span>
%h2#links Links
%ul
%li
%a{:href => "http://emberup.co/dynamic-component-rendering/"} Dynamic component rendering
%li
%a{:href => "https://github.com/mixonic/ember-community-versions"} Ember Community Versions
54 changes: 54 additions & 0 deletions public/css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
*, *:before, *:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

body {
background: white;
font-family: 'Georgia', serif;
margin: 0;
padding: 0;
}

#content {
max-width: 600px;
margin: 0 auto;
position: relative;
padding: 20px;
}

h1, h2 {
font-family: 'Source Sans Pro', sans-serif;
}

h1 {
font-size: 72px;
line-height: 1.7;
margin: 0;
padding: 0;

}

h2 {
color: #333;
}

p {
color: #444;
line-height: 1.6;
font-size: 18px;
}

li {
line-height: 1.6;
font-size: 18px;
}

a {
color: #d01040;
}

a:visited {
color: rgba(208, 16, 64, 0.6);
}
17 changes: 17 additions & 0 deletions public/v1/badge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(function() {
var elements = document.getElementsByClassName('embadge'),
url = '//embadge.io/v1/badge.svg';
for (i=0; i < elements.length; i++) {
var img = document.createElement('img'),
el = elements[i];
if (el.dataset.range) {
img.src = url + '?range=' + el.dataset.range;
} else {
img.src = url + '?start=' + el.dataset.start;
if (el.dataset.end) {
img.src += '&end=' + el.dataset.end;
}
}
el.appendChild(img);
};
})();

0 comments on commit c48f2df

Please sign in to comment.