Skip to content

Commit

Permalink
#226 Make librejs like FreedomSponsors
Browse files Browse the repository at this point in the history
  • Loading branch information
tonylampada committed Oct 28, 2014
1 parent e963918 commit 9070ed4
Show file tree
Hide file tree
Showing 34 changed files with 154 additions and 452 deletions.
2 changes: 1 addition & 1 deletion djangoproject/grunt/concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function(grunt, options){
P + '/angularutils/*.js',
P + '/contenteditable/*.js',
P + '/issuecards/*.js',
P + '/soapi/*.js',
P + '/so/*.js',
P + '/tags/tag_api.js',
P + '/tags/taglist.js',
'statfiles/static/js-generated/fs-templates.js'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 46 additions & 20 deletions djangoproject/statfiles/static/js-generated/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ if(!FS.dependencies){
}

angular.module('fs', FS.dependencies).config(
function($interpolateProvider){
function($interpolateProvider, $httpProvider){
$interpolateProvider.startSymbol('{[{').endSymbol('}]}');
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
}
);

var fsapi_mod = angular.module('fsapi', []);
angular.module('fsapi', []);

fsapi_mod.factory('FSApi', function(){
angular.module('fsapi').factory('FSApi', function(){

function list_issues(project_id, sponsoring, offset, count){
var params = {
Expand Down Expand Up @@ -53,9 +55,9 @@ fsapi_mod.factory('FSApi', function(){
};
});

var fsapi_mod = angular.module('fslinks', []);
angular.module('fslinks', []);

fsapi_mod.factory('FSLinks', function(){
angular.module('fslinks').factory('FSLinks', function(){

function issue_link(issue){
return issue.issue_link;
Expand Down Expand Up @@ -141,8 +143,8 @@ function get4Sponsors(issue){
https://github.com/freedomsponsors/www.freedomsponsors.org/blob/master/AGPL_license.txt
*/

var mod = angular.module('activitylist', ['fsapi']);
mod.directive('activitylist', function() {
angular.module('activitylist', ['fsapi']);
angular.module('activitylist').directive('activitylist', function() {
return {
restrict: 'E',
replace: true,
Expand Down Expand Up @@ -194,8 +196,8 @@ mod.directive('activitylist', function() {
}
});

var mod = angular.module('angularutils', []);
mod.directive('textWithMarkdownPreview', function() {
angular.module('angularutils', []);
angular.module('angularutils').directive('textWithMarkdownPreview', function() {
return {
restrict: 'E',
replace: true,
Expand All @@ -215,7 +217,7 @@ mod.directive('textWithMarkdownPreview', function() {
}
});

mod.directive('watchIssue', function() {
angular.module('angularutils').directive('watchIssue', function() {
return {
restrict: 'E',
replace: true,
Expand Down Expand Up @@ -252,7 +254,7 @@ mod.directive('watchIssue', function() {
}
});

mod.directive('multilineEllipsis', function () {
angular.module('angularutils').directive('multilineEllipsis', function () {
return {
restrict: 'A',
link: function (scope, element, attr) {
Expand Down Expand Up @@ -320,9 +322,9 @@ $.ajaxSetup({
}
}
});
var mod = angular.module('fswatch', ['fsapi']);
angular.module('fswatch', ['fsapi']);

mod.directive('watchEntity', function() {
angular.module('fswatch').directive('watchEntity', function() {
return {
restrict: 'E',
replace: true,
Expand Down Expand Up @@ -419,8 +421,8 @@ angular.module('contenteditable', []).
}
};
});
var mod = angular.module('issuecards', ['fsapi', 'fslinks', 'angularutils']);
mod.directive('issueCards', function() {
angular.module('issuecards', ['fsapi', 'fslinks', 'angularutils']);
angular.module('issuecards').directive('issueCards', function() {
return {
restrict: 'E',
replace: true,
Expand Down Expand Up @@ -570,6 +572,30 @@ mod.directive('issueCards', function() {
};
});

angular.module('soapi', []);

angular.module('soapi').factory('SOApi', function($http){
var get_tags = "https://api.stackexchange.com/2.1/tags";


function getTags(s){
return $http({
url: get_tags,
method: "GET",
params: {
order: 'desc',
sort: 'popular',
inname: s,
site: 'stackoverflow'
}
});
}

return {
getTags: getTags
};
})

/**
*
Copyright (C) 2013 FreedomSponsors
Expand All @@ -593,9 +619,9 @@ mod.directive('issueCards', function() {
*/


var mod = angular.module('tagapi', []);
angular.module('tagapi', []);

mod.factory('TagApi', function($http) {
angular.module('tagapi').factory('TagApi', function($http) {
var add_tag = '/core/json/add_tag';
var remove_tag = '/core/json/remove_tag';

Expand Down Expand Up @@ -650,8 +676,8 @@ mod.factory('TagApi', function($http) {
https://github.com/freedomsponsors/www.freedomsponsors.org/blob/master/AGPL_license.txt
*/

var mod = angular.module('taglist', ['soapi', 'tagapi']);
mod.directive('taglist', function() {
angular.module('taglist', ['soapi', 'tagapi']);
angular.module('taglist').directive('taglist', function() {
return {
restrict: 'E',
replace: true,
Expand Down Expand Up @@ -758,7 +784,7 @@ angular.module('fs').run(['$templateCache', function($templateCache) {


$templateCache.put('/static/js/issuecards/issuecards.html',
"<div class=card-list-section><div class=card-list-header><h3 class=\"boxed medium\">{{ label }}</h3><a href class=\"fs-button square grey less\" ng-class=\"{'disabled' : no_less()}\" ng-click=less()>«</a> <a href class=\"fs-button square grey more\" ng-class=\"{'disabled' : no_more()}\" ng-click=more()>»</a> <img ng-show=is_loading src=/static/img2/ajax-loader.gif> <a href=\"/search/?project_id={[{ projectId }]}&operation={[{getViewAllOperation()}]}\" class=\"fs-button medium grey view-all right\">View All</a></div><div class=column-wrapper><div ng-repeat=\"issue in issues\" ng-include=getInclude()></div></div></div>"
"<div class=card-list-section><div class=card-list-header><h3 class=\"boxed medium\">{{ label }}</h3><a href class=\"fs-button square grey less\" ng-class=\"{'disabled' : no_less()}\" ng-click=less()>&laquo;</a> <a href class=\"fs-button square grey more\" ng-class=\"{'disabled' : no_more()}\" ng-click=more()>&raquo;</a> <img ng-show=is_loading src=/static/img2/ajax-loader.gif> <a href=\"/search/?project_id={[{ projectId }]}&operation={[{getViewAllOperation()}]}\" class=\"fs-button medium grey view-all right\">View All</a></div><div class=column-wrapper><div ng-repeat=\"issue in issues\" ng-include=getInclude()></div></div></div>"
);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
https://github.com/freedomsponsors/www.freedomsponsors.org/blob/master/AGPL_license.txt
*/

var mod = angular.module('activitylist', ['fsapi']);
mod.directive('activitylist', function() {
angular.module('activitylist', ['fsapi']);
angular.module('activitylist').directive('activitylist', function() {
return {
restrict: 'E',
replace: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var mod = angular.module('angularutils', []);
mod.directive('textWithMarkdownPreview', function() {
angular.module('angularutils', []);
angular.module('angularutils').directive('textWithMarkdownPreview', function() {
return {
restrict: 'E',
replace: true,
Expand All @@ -19,7 +19,7 @@ mod.directive('textWithMarkdownPreview', function() {
}
});

mod.directive('watchIssue', function() {
angular.module('angularutils').directive('watchIssue', function() {
return {
restrict: 'E',
replace: true,
Expand Down Expand Up @@ -56,7 +56,7 @@ mod.directive('watchIssue', function() {
}
});

mod.directive('multilineEllipsis', function () {
angular.module('angularutils').directive('multilineEllipsis', function () {
return {
restrict: 'A',
link: function (scope, element, attr) {
Expand Down
4 changes: 2 additions & 2 deletions djangoproject/statfiles/static/js/angularutils/watch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var mod = angular.module('fswatch', ['fsapi']);
angular.module('fswatch', ['fsapi']);

mod.directive('watchEntity', function() {
angular.module('fswatch').directive('watchEntity', function() {
return {
restrict: 'E',
replace: true,
Expand Down
4 changes: 2 additions & 2 deletions djangoproject/statfiles/static/js/fsapi.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var fsapi_mod = angular.module('fsapi', []);
angular.module('fsapi', []);

fsapi_mod.factory('FSApi', function(){
angular.module('fsapi').factory('FSApi', function(){

function list_issues(project_id, sponsoring, offset, count){
var params = {
Expand Down
4 changes: 2 additions & 2 deletions djangoproject/statfiles/static/js/fsapi_mock.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion djangoproject/statfiles/static/js/fsbase.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ if(!FS.dependencies){
}

angular.module('fs', FS.dependencies).config(
function($interpolateProvider){
function($interpolateProvider, $httpProvider){
$interpolateProvider.startSymbol('{[{').endSymbol('}]}');
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
}
);
4 changes: 2 additions & 2 deletions djangoproject/statfiles/static/js/fslinks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var fsapi_mod = angular.module('fslinks', []);
angular.module('fslinks', []);

fsapi_mod.factory('FSLinks', function(){
angular.module('fslinks').factory('FSLinks', function(){

function issue_link(issue){
return issue.issue_link;
Expand Down
4 changes: 2 additions & 2 deletions djangoproject/statfiles/static/js/fslinks_sandbox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var fsapi_mod = angular.module('fslinks', []);
angular.module('fslinks', []);

fsapi_mod.factory('FSLinks', function(){
angular.module('fslinks').factory('FSLinks', function(){

function issue_link(issue){
return "/sandbox/issue"
Expand Down
4 changes: 2 additions & 2 deletions djangoproject/statfiles/static/js/issuecards/issuecards.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="card-list-section">
<div class="card-list-header">
<h3 class="boxed medium">{{ label }}</h3>
<a href class="fs-button square grey less" ng-class="{'disabled' : no_less()}" ng-click="less()">«</a>
<a href class="fs-button square grey more" ng-class="{'disabled' : no_more()}" ng-click="more()">»</a>
<a href class="fs-button square grey less" ng-class="{'disabled' : no_less()}" ng-click="less()">&laquo;</a>
<a href class="fs-button square grey more" ng-class="{'disabled' : no_more()}" ng-click="more()">&raquo;</a>
<img ng-show="is_loading" src="/static/img2/ajax-loader.gif">
<a href="/search/?project_id={[{ projectId }]}&operation={[{getViewAllOperation()}]}" class="fs-button medium grey view-all right">View All</a>
</div>
Expand Down
4 changes: 2 additions & 2 deletions djangoproject/statfiles/static/js/issuecards/issuecards.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var mod = angular.module('issuecards', ['fsapi', 'fslinks', 'angularutils']);
mod.directive('issueCards', function() {
angular.module('issuecards', ['fsapi', 'fslinks', 'angularutils']);
angular.module('issuecards').directive('issueCards', function() {
return {
restrict: 'E',
replace: true,
Expand Down
4 changes: 2 additions & 2 deletions djangoproject/statfiles/static/js/so/soapi.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var mod = angular.module('soapi', []);
angular.module('soapi', []);

mod.factory('SOApi', function($http){
angular.module('soapi').factory('SOApi', function($http){
var get_tags = "https://api.stackexchange.com/2.1/tags";


Expand Down
4 changes: 2 additions & 2 deletions djangoproject/statfiles/static/js/tags/tag_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
*/


var mod = angular.module('tagapi', []);
angular.module('tagapi', []);

mod.factory('TagApi', function($http) {
angular.module('tagapi').factory('TagApi', function($http) {
var add_tag = '/core/json/add_tag';
var remove_tag = '/core/json/remove_tag';

Expand Down
4 changes: 2 additions & 2 deletions djangoproject/statfiles/static/js/tags/tag_api_mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
https://github.com/freedomsponsors/www.freedomsponsors.org/blob/master/AGPL_license.txt
*/

var mod = angular.module('tagapi', []);
angular.module('tagapi', []);

mod.factory('TagApi', function() {
angular.module('tagapi').factory('TagApi', function() {
function addTag(name, objtype, objid){

}
Expand Down
4 changes: 2 additions & 2 deletions djangoproject/statfiles/static/js/tags/taglist.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
https://github.com/freedomsponsors/www.freedomsponsors.org/blob/master/AGPL_license.txt
*/

var mod = angular.module('taglist', ['soapi', 'tagapi']);
mod.directive('taglist', function() {
angular.module('taglist', ['soapi', 'tagapi']);
angular.module('taglist').directive('taglist', function() {
return {
restrict: 'E',
replace: true,
Expand Down
19 changes: 9 additions & 10 deletions djangoproject/templates/core2/change_username.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
{% endblock %}

{% block head %}
<script>
if(!window.FS){
window.FS = {};
}
FS.dependencies = ['fsapi'];
</script>
<script src="/static/js/angular.min.js"></script>
<script src="/static/js/fsapi.js"></script>
<script src="/static/js/fsutil.js"></script>
<script src="/static/js-generated/fs.js"></script>
<script>
angular.module('main', ['fsapi']).config(
function($interpolateProvider, $httpProvider){
$interpolateProvider.startSymbol('{[{').endSymbol('}]}');
$httpProvider.defaults.xsrfCookieName = 'csrftoken';
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
}
).controller('ChangeUsernameCtrl', function ChangeUsernameCtrl($scope, FSApi){
angular.module('fs').controller('ChangeUsernameCtrl', function ChangeUsernameCtrl($scope, FSApi){
$scope.new_username = '{{ user.username }}';

$scope.keypress = function(evt){
Expand Down Expand Up @@ -48,7 +47,7 @@


{% block mainContent%}
<div class="content" align="center" ng-app="main" ng-controller="ChangeUsernameCtrl">
<div class="content" align="center" ng-app="fs" ng-controller="ChangeUsernameCtrl">
<div class="content-section" align="left">
{% if can_change %}
<h2>Change username</h2>
Expand Down
2 changes: 1 addition & 1 deletion djangoproject/templates/core2/empty_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
{% if BTC2USD %}
var BTC2USD = {{ BTC2USD }};
{% else %}
var BTC2USD = 651.04;
var BTC2USD = 351.04;
{% endif %}
{% endlocalize %}
</script>
Expand Down
4 changes: 4 additions & 0 deletions djangoproject/templates/core2/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
$scope.issues_sponsoring = issues_sponsoring;
$scope.issues_proposed = {{ issues_kickstarting|safe }};
}

angular.module('fs').run(function($templateCache){
window.TC = $templateCache;
});
</script>
{% endblock %}

Expand Down
Loading

0 comments on commit 9070ed4

Please sign in to comment.