Skip to content

Commit

Permalink
stars and forks badges, fix #44
Browse files Browse the repository at this point in the history
  • Loading branch information
dnbard committed Jul 22, 2014
1 parent 4e01f45 commit e7d3cea
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Brackets Extension Rating

A [brackets IDE](http://brackets.io) extension to display other extensions statictics based on downloads.
[Brackets IDE](http://brackets.io) extension to display other extensions statictics based on downloads.

## Brackets extension

Expand Down
34 changes: 34 additions & 0 deletions extension/achievements/mostForks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
define(function(require, exports, module){
var Achievement = require('./achievement'),
config = require('../config'),
_ = require('../vendor/lodash.min'),
locale = require('../services/locale'),
numberOfTopExtensoins = 7;

function MostForksAchievement(){
this.calculate = function(extensions){
extensions = _.sortBy(extensions, function(el){
return el.forks?
- el.forks:
0;
});

for (var i = 0; i < numberOfTopExtensoins; i ++){
if (!extensions[i]){
break;
}
this.writeBadge(i, extensions[i]);
}
}

this.getTag = function(rating){
return _.template('<span title="${title}" class="ext-badge ext-badge-forks"><i class="fa fa-code-fork"></i></span>',{
title: locale.get('badgeForksTitle')
});
}
}

MostForksAchievement.prototype = Achievement;

module.exports = MostForksAchievement;
});
34 changes: 34 additions & 0 deletions extension/achievements/mostStars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
define(function(require, exports, module){
var Achievement = require('./achievement'),
config = require('../config'),
_ = require('../vendor/lodash.min'),
locale = require('../services/locale'),
numberOfTopExtensoins = 7;

function MostStarsAchievement(){
this.calculate = function(extensions){
extensions = _.sortBy(extensions, function(el){
return el.stars?
- el.stars:
0;
});

for (var i = 0; i < numberOfTopExtensoins; i ++){
if (!extensions[i]){
break;
}
this.writeBadge(i, extensions[i]);
}
}

this.getTag = function(rating){
return _.template('<span title="${title}" class="ext-badge ext-badge-stars"><i class="fa fa-star"></i></span>',{
title: locale.get('badgeStarsTitle')
});
}
}

MostStarsAchievement.prototype = Achievement;

module.exports = MostStarsAchievement;
});
3 changes: 3 additions & 0 deletions extension/locale/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ define(function (require, exports, module){

badgeNew: 'New',
badgeNewTitle: 'New extension',

badgeStarsTitle: 'Most popular extension on GitHub', //0.4.0
badgeForksTitle: 'Most forked extension on GitHub', //0.4.0
/*END of BADGES*/

//Detailed info about ##
Expand Down
4 changes: 4 additions & 0 deletions extension/services/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ define(function(require, exports, module){
NewExtensionAchievement = require('../achievements/new'),
AuthorAchievement = require('../achievements/author'),
AdobeAchievement = require('../achievements/adobe'),
MostStarsAchievement = require('../achievements/mostStars'),
MostForksAchievement = require('../achievements/mostForks'),
state = config.state;

function getDownloadsCounterByDate(array, date){
Expand Down Expand Up @@ -51,6 +53,8 @@ define(function(require, exports, module){
//achievements.push(new UpdatedAchievement());
//achievements.push(new AuthorAchievement());
achievements.push(new AdobeAchievement());
achievements.push(new MostStarsAchievement());
achievements.push(new MostForksAchievement());
}

$.ajax({
Expand Down
11 changes: 10 additions & 1 deletion extension/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ span.ext-daily{

.ext-badges > .ext-badge{
padding: 2px 6px;
margin-right: 2px;
margin: 1px 2px 1px 0px;
border-radius: 3px;
color: white;
text-shadow: 0 0 5px black;
display: inline-block;
}

.ext-badges > .ext-badge-top{
Expand All @@ -44,6 +45,14 @@ span.ext-daily{
background: linear-gradient(to bottom, #1e5799 0%,#207cca 59%,#ffea30 60%,#fceb88 100%);
}

.ext-badges > .ext-badge-stars{
background-color: #2751BE;
}

.ext-badges > .ext-badge-forks{
background-color: rgb(55, 152, 11);
}

.fa{
font-size: 14px;
}
Expand Down

0 comments on commit e7d3cea

Please sign in to comment.