Skip to content

Commit

Permalink
Add one more section to the main page:
Browse files Browse the repository at this point in the history
Old repos section.
  • Loading branch information
ArnonEilat committed Jun 14, 2014
1 parent 8ab7684 commit e0ddc12
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 36 deletions.
10 changes: 9 additions & 1 deletion src/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,15 @@
margin: 0 auto;
max-width: 768px;
}

.old-eknights-warp{}
.old-eknights-warp h2{
direction: rtl;
font-weight: 100;
border-top: 2px #212123 dashed;
padding: 0px 17px 0px 0px;
margin: 1em 0px 0px 0px;
color: #212123;
}
.eKnight {
box-shadow: 0px 3px 2px #aab2bd;
direction: rtl;
Expand Down
27 changes: 27 additions & 0 deletions src/main-page/eKnight.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

<h3>{{eKnight.name}}</h3>
<p>{{eKnight.about}}</p>
<ul class="status-list">
<li>
<strong>סטטוס: </strong> {{eKnight.status}}
</li>
<li>
<strong>רמת כניסה: </strong> {{eKnight.status}}
</li>
<li title="{{eKnight.lastUpdate| date:'בdd לM yyyy בשעה HH:mm'}}">התעדכן לאחרונה {{eKnight.lastUpdate|hebTimeAgo}}</li>
</ul>

<div class="button-bar">
<a class="btn" href="{{eKnight.permalink}}">
<span class="btn-icon fa fa-home"></span>
<span class="btn-text">עמוד הבית</span>
</a>
<a class="btn" href="#/{{eKnight.slug}}" >
<span class="btn-icon fa fa-comments-o"></span>
<span class="btn-text">עמוד החשמביר</span>
</a>
<a class="btn" href="{{eKnight.github_repo}}">
<span class="btn-icon fa fa-github"></span>
<span class="btn-text">גיטהאב</span>
</a>
</div>
63 changes: 60 additions & 3 deletions src/main-page/filters.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,61 @@

angular.module('timeUtill', []).factory('timeUtill', function() {

/**
* @constructor
*/
function timeUtill() {
/**
* @description Finds how many full days lie between two dates.
* @param {Date} firstDate
* @param {Date} secondDate
* @returns {Number}
*/
this.dayDiff = function(firstDate, secondDate) {
var timeDiff = Math.abs(firstDate.getTime() - secondDate.getTime());
return Math.ceil(timeDiff / (1000 * 3600 * 24));
};
}
return new timeUtill();
});

/**
* @description
* @param {Object} timeUtill module
*/
App.filter("ageGroup", function ageGroup(timeUtill) {
var today = new Date();
var threeMonthsInDays = 90; // = 3*30

/**
* @description If key is true return all the eKnights which updated in the last 3 months.
* If key is false return all the eKnights which not updated in the last 3 months.
* @param {Array} array Of eKnights to filter.
* @param {boolean} key
*/
return function(array, key) {
if (!angular.isArray(array))
return;
function filterFunc(eKnight) {
var lastUpdate = new Date(eKnight.lastUpdate);
var diff = timeUtill.dayDiff(lastUpdate, today);

if (key === true)
if (diff > threeMonthsInDays)
return false;
else
return true;
if (key === false) // AKA else
if (diff < threeMonthsInDays)
return false;
else
return true;
}

var filteredArr = array.filter(filterFunc);
return filteredArr;
};
});
/**
* @description Filter that takes items with empty name from ordered array and
* places them at the end.
Expand All @@ -19,10 +77,9 @@ App.filter("emptyToEnd", function emptyToEnd() {
return present.concat(empty);
};
});

/**
*@description Format a JavaScript Date as a string stating the time elapsed
*@see https://stackoverflow.com/questions/3177836/how-to-format-time-since-xxx-e-g-4-minutes-ago-similar-to-stack-exchange-site
* @description Format a JavaScript Date as a string stating the time elapsed
* @see https://stackoverflow.com/questions/3177836/how-to-format-time-since-xxx-e-g-4-minutes-ago-similar-to-stack-exchange-site
*/
App.filter('hebTimeAgo', function timeAgo() {
/**
Expand Down
39 changes: 12 additions & 27 deletions src/main-page/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,21 @@ <h2>מבית הסדנא לידע ציבורי</h2>
</div>
</div>
<div class="eknights">
<article ng-repeat="eKnight in (eKnights|orderBy:'lastUpdate':true|emptyToEnd:'lastUpdate')" class="eKnight">
<h3>{{eKnight.name}}</h3>
<p>{{eKnight.about}}</p>
<ul class="status-list">
<li>
<strong>סטטוס: </strong> {{eKnight.status}}
</li>
<li>
<strong>רמת כניסה: </strong> {{eKnight.status}}
</li>
<li title="{{eKnight.lastUpdate| date:'בdd לM yyyy בשעה HH:mm'}}">התעדכן לאחרונה {{eKnight.lastUpdate|hebTimeAgo}}</li>
</ul>

<div class="button-bar">
<a class="btn" href="{{eKnight.permalink}}">
<span class="btn-icon fa fa-home"></span>
<span class="btn-text">עמוד הבית</span>
</a>
<a class="btn" href="#/{{eKnight.slug}}" >
<span class="btn-icon fa fa-comments-o"></span>
<span class="btn-text">עמוד החשמביר</span>
</a>
<a class="btn" href="{{eKnight.github_repo}}">
<span class="btn-icon fa fa-github"></span>
<span class="btn-text">גיטהאב</span>
</a>
</div>
<article ng-repeat="eKnight in (eKnights|orderBy:'lastUpdate':true|emptyToEnd:'lastUpdate'|ageGroup:true)"
class="eKnight"
data-ng-include="relativizePath('main-page/eKnight.html')">
</article>
</div>

<div class="old-eknights-warp" ng-if="oldReposExists == true">
<h2>לא התעדכן כבר מלא זמן:</h2>
<div class="eknights">
<article ng-repeat="eKnight in (eKnights|orderBy:'lastUpdate':true|emptyToEnd:'lastUpdate'|ageGroup:false)"
class="eKnight"
data-ng-include="relativizePath('main-page/eKnight.html')">
</article>
</div>
</div>
</div>

<div id="small-repos-warp" ng-include="relativizePath('main-page/small_repos.html')"></div>
Expand Down
17 changes: 14 additions & 3 deletions src/main-page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* @param {Object} $scope See <a href="https://docs.angularjs.org/guide/scope">What are Scopes?</a>
* @param {Object} $window A reference to the browser's window object. See <a href="https://docs.angularjs.org/api/ng/service/$window">$window</a>
* @param {Object} $http service. See: <a href="https://docs.angularjs.org/api/ng/service/$http">$http</a>
* @param {Object} timeUtill
*/
function indexCtrl($scope, $window, $http) {
function indexCtrl($scope, $window, $http, timeUtill) {
$scope.relativizePath = $window.CONFIG.relativizePath;

var unknownLastUpdate = [];
Expand All @@ -30,7 +31,7 @@ function indexCtrl($scope, $window, $http) {
for (var i = 0; i < updatedData.length; i++) {
if (updatedData[i].html_url.toLowerCase() === url) {
eKnight.lastUpdate = updatedData[i].pushed_at;
//break;
//break;
}
}
if (!eKnight.lastUpdate)
Expand Down Expand Up @@ -58,6 +59,16 @@ function indexCtrl($scope, $window, $http) {
updateByRepoUrl(--index);
}
updateByRepoUrl(index);

$scope.oldReposExists = false;
var today = new Date();
var threeMonthsInDays = 90; // = 3*30
$scope.eKnights.forEach(function(eKnight) {
// console.log(new Date(eKnight.lastUpdate));
var diff = timeUtill.dayDiff(new Date(eKnight.lastUpdate), today);
if (diff > threeMonthsInDays)
$scope.oldReposExists = true;
});
}
$scope.small_repos = $window.small_repos;
}
Expand All @@ -66,7 +77,7 @@ function indexCtrl($scope, $window, $http) {
method: 'GET',
url: 'https://api.github.com/orgs/hasadna/repos?type=all'
});

// When the request success - call addLastUpdateProperty function
request.success(addLastUpdateProperty);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var App = angular.module('App', [
'ngResource', 'ngRoute', 'ngSanitize', 'ui.utils', 'App.filters',
'HebUtill', 'commentsHandler', 'arrayUtill', 'checkboxesFilter', 'issuesLoader'
'HebUtill', 'commentsHandler', 'arrayUtill', 'checkboxesFilter', 'issuesLoader', 'timeUtill'
]);


Expand All @@ -13,7 +13,7 @@ var App = angular.module('App', [
App.config(function($routeProvider) {

var path = window.CONFIG.PATH;

$routeProvider.when('/:eKnight/piChart', {
controller: 'piChartCtrl',
templateUrl: path + 'visualizations/piVisualization/index.html',
Expand Down

0 comments on commit e0ddc12

Please sign in to comment.