Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foundation update #13

Closed
wants to merge 10 commits into from
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"trailing": true,
"smarttabs": true,
"jquery": true,
"sub": true,
"predef": [
// Third-Party
"_",
Expand Down
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
language: node_js
node_js:
- '0.10'
before_install:
- gem update --system
- gem install sass --version '=3.2.12'
- gem install compass --version '=0.12.2'
- npm install -g grunt-cli
14 changes: 6 additions & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ module.exports = function (grunt) {
}
},




// Compiles Sass to CSS and generates necessary files if requested
compass: {
options: {
Expand Down Expand Up @@ -187,7 +184,8 @@ module.exports = function (grunt) {
'bower-install': {
app: {
html: '<%= yeoman.app %>/index.html',
ignorePath: '<%= yeoman.app %>/'
ignorePath: '<%= yeoman.app %>/',
exclude: ['<%= yeoman.app %>/bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap.js']
}
},

Expand All @@ -198,7 +196,7 @@ module.exports = function (grunt) {
src: [
'<%= yeoman.dist %>/scripts/{,*/}*.js',
'<%= yeoman.dist %>/styles/{,*/}*.css',
'<%= yeoman.dist %>/images/{,*/}*.{gif,jpeg,jpg,png,webp}',
'<%= yeoman.dist %>/images/{,*/}*',
'<%= yeoman.dist %>/styles/fonts/{,*/}*.*'
]
}
Expand All @@ -218,7 +216,7 @@ module.exports = function (grunt) {
// Performs rewrites based on rev and the useminPrepare configuration
usemin: {
options: {
assetsDirs: ['<%= yeoman.dist %>']
assetsDirs: ['<%= yeoman.dist %>', '<%= yeoman.dist %>/images']
},
html: ['<%= yeoman.dist %>/{,*/}*.html'],
css: ['<%= yeoman.dist %>/styles/{,*/}*.css']
Expand Down Expand Up @@ -303,10 +301,10 @@ module.exports = function (grunt) {
src: [
'*.{ico,png,txt}',
'.htaccess',
'images/{,*/}*.webp',
'images/{,*/}*',
'{,*/}*.html',
'styles/fonts/{,*/}*.*',
'bower_components/' + (this.includeCompass ? 'sass-' : '') + 'bootstrap/' + (this.includeCompass ? 'fonts/' : 'dist/fonts/') +'*.*'
'bower_components/bootstrap/vendor/assets/fonts/bootstrap/fonts/*.*'
]
}]
},
Expand Down
46 changes: 30 additions & 16 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css styles/vendor.css -->
<!-- bower:css -->

<!-- endbower -->
<!-- endbuild -->

<!-- build:css(.tmp) styles/main.css -->
<link rel="stylesheet" href="styles/main.css">
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->

<script src="bower_components/modernizr/modernizr.js"></script>

</head>
Expand All @@ -44,6 +45,14 @@ <h1>TasteMusic</h1>
<p><a class="btn btn-lg btn-success" href="https://github.com/tastejs/TasteMusic/issues/1" target="_blank">Share Your Music</a></p>
</div>

<a href="https://soundcloud.com/tfr-royal/of-monsters-and-men-dirty-paws" title="Play Track" class="track">Play Track</a>


<div class="sm2-container">
<div class="ui360">
</div>
</div>

<div class="row marketing">
<h3>List of Tracks</h3>
<div class="col-md-12" id="shared-links">
Expand All @@ -60,9 +69,13 @@ <h3>List of Tracks</h3>

<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/underscore/underscore.js"></script>
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/lodash/dist/lodash.min.js"></script>
<script src="bower_components/get-urls/get-urls.js"></script>
<script src="bower_components/soundmanager/script/soundmanager2-nodebug-jsmin.js"></script>
<script src="bower_components/soundmanager/demo/mp3-player-button/script/mp3-player-button.js"></script>
<!-- endbower -->
<script src="http://connect.soundcloud.com/sdk.js"></script>
<!-- endbuild -->

<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
Expand All @@ -76,23 +89,24 @@ <h3>List of Tracks</h3>
</script>

<!-- build:js scripts/plugins.js -->
<script src="bower_components/sass-bootstrap/js/affix.js"></script>
<script src="bower_components/sass-bootstrap/js/alert.js"></script>
<script src="bower_components/sass-bootstrap/js/dropdown.js"></script>
<script src="bower_components/sass-bootstrap/js/tooltip.js"></script>
<script src="bower_components/sass-bootstrap/js/modal.js"></script>
<script src="bower_components/sass-bootstrap/js/transition.js"></script>
<script src="bower_components/sass-bootstrap/js/button.js"></script>
<script src="bower_components/sass-bootstrap/js/popover.js"></script>
<script src="bower_components/sass-bootstrap/js/carousel.js"></script>
<script src="bower_components/sass-bootstrap/js/scrollspy.js"></script>
<script src="bower_components/sass-bootstrap/js/collapse.js"></script>
<script src="bower_components/sass-bootstrap/js/tab.js"></script>
<script src="bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/affix.js"></script>
<script src="bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/alert.js"></script>
<script src="bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/dropdown.js"></script>
<script src="bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/tooltip.js"></script>
<script src="bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/modal.js"></script>
<script src="bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/transition.js"></script>
<script src="bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/button.js"></script>
<script src="bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/popover.js"></script>
<script src="bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/carousel.js"></script>
<script src="bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/scrollspy.js"></script>
<script src="bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/collapse.js"></script>
<script src="bower_components/bootstrap-sass/vendor/assets/javascripts/bootstrap/tab.js"></script>
<!-- endbuild -->

<!-- build:js({app,.tmp}) scripts/main.js -->
<script src="scripts/helpers.js"></script>
<script src="scripts/comments_parser.js"></script>
<script src="scripts/player.js"></script>
<script src="scripts/main.js"></script>
<!-- endbuild -->
</body>
Expand Down
35 changes: 20 additions & 15 deletions app/scripts/comments_parser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/*jslint indent: false, global app: true */
;(function(_, window, undefined) {
'use strict';

var app = window.app;

// The result object after we're done parsing the URLs.
var result = {
htmlList: document.createElement('ol'),
Expand All @@ -16,8 +19,8 @@


// Returns true if a URL matches any of the provided domain names.
var domainMatch = function(url, domains) {
var r = false, url = url.toLowerCase();
var domainMatch = function(URL, domains) {
var r = false, url = URL.toLowerCase();

if (_.isString(domains)) {
return url.indexOf(domains) > 1 ? true : false;
Expand All @@ -30,13 +33,13 @@
});

return r;
}
};


var item; // Creates a list-item with a link for each URL.
function buildList(url) {
item = document.createElement('li');
item.innerHTML = '<a href="'+url+'" target="_blank">' + url + '</a>';
item.innerHTML = '<a href="'+url+'" target="_blank" class="track">' + url + '</a>';
result.htmlList.appendChild(item);
}

Expand Down Expand Up @@ -90,7 +93,7 @@
}

// Send ajax
app.http.get({
new app.http.get({
url: endpoint,

success: function(data, status, statusText) {
Expand All @@ -100,28 +103,30 @@
if (self.comments.length > 0) {
self.build();
} else {
self.options.fail('No more links are available.');
self.options.fail('No more links are available. '+statusText);
}
}
},

error: function(xhr, status, statusText) {
self.comments = [];
self.build();
self.options.fail(status + ' ' + statusText);
}
});
},

// Collect URLs from a single chunk of string
collectUrls: function(string_chunk) {
var string_lines = [];
collectUrls: function(stringChunk) {
var stringLines = [];
var words = [];
var URLs = [];

// Split on new lines
string_lines = string_chunk.split(app.regex.newline);
stringLines = stringChunk.split(app.regex.newline);

// Get words out of each line
_.each(_.compact(string_lines), function(line) {
_.each(_.compact(stringLines), function(line) {
words.push(line.split(app.regex.space));
});

Expand All @@ -140,25 +145,25 @@

build: function() {
var self = this;
var comment_urls;
var commentUrls;
var currentLength = 0;
var commentsLength = self.comments.length;

// Collect urls from comment's body
_.each(self.comments, function(comment) {
comment_urls = self.collectUrls(comment['body']);
commentUrls = self.collectUrls(comment['body']);

// Simply concat them to the result array
result.array = result.array.concat(comment_urls);
result.array = result.array.concat(commentUrls);

// Each URL in the comment is added to a
// collection type in the result object
_.each(comment_urls, addToCollections);
_.each(commentUrls, addToCollections);

currentLength += 1;

// Are we done?
if (currentLength == commentsLength) {
if (currentLength === commentsLength) {
self.complete();
return;
}
Expand Down
57 changes: 29 additions & 28 deletions app/scripts/helpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/*jslint indent: false */

;(function(_, window, undefined) {
'use strict';

Expand All @@ -11,61 +13,60 @@


// Regex: https://gist.github.com/dperini/729294
var re_weburl = new RegExp(
"^" +
var reWebUrl = new RegExp(
'^' +
// protocol identifier
"(?:(?:https?|ftp)://)" +
'(?:(?:https?|ftp)://)' +
// user:pass authentication
"(?:\\S+(?::\\S*)?@)?" +
"(?:" +
'(?:\\S+(?::\\S*)?@)?' +
'(?:' +
// IP address exclusion
// private & local networks
"(?!10(?:\\.\\d{1,3}){3})" +
"(?!127(?:\\.\\d{1,3}){3})" +
"(?!169\\.254(?:\\.\\d{1,3}){2})" +
"(?!192\\.168(?:\\.\\d{1,3}){2})" +
"(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})" +
'(?!10(?:\\.\\d{1,3}){3})' +
'(?!127(?:\\.\\d{1,3}){3})' +
'(?!169\\.254(?:\\.\\d{1,3}){2})' +
'(?!192\\.168(?:\\.\\d{1,3}){2})' +
'(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})' +
// IP address dotted notation octets
// excludes loopback network 0.0.0.0
// excludes reserved space >= 224.0.0.0
// excludes network & broacast addresses
// (first & last IP address of each class)
"(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" +
"(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" +
"(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" +
"|" +
'(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])' +
'(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}' +
'(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))' +
'|' +
// host name
"(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)" +
'(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)' +
// domain name
"(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*" +
'(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*' +
// TLD identifier
"(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))" +
")" +
'(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))' +
')' +
// port number
"(?::\\d{2,5})?" +
'(?::\\d{2,5})?' +
// resource path
"(?:/[^\\s]*)?" +
"$", "i"
);
'(?:/[^\\s]*)?' +
'$', 'i'
);


// Ajax methods
var http = app.http = {
window.app.http = {
// [CORS]:
// The request will succeed if the Browser supports
// XHR2/CORS because GitHub also allows CORS requests.
get: function(options) {
var xhr;

// Bypass cache by adding timestamp at the end of the url.
var url = options.url + ((/\?/).test(options.url) ? "&" : "?") + (+(new Date));
var url = options.url + ((/\?/).test(options.url) ? '&' : '?') + (+(new Date()));

// Only modern Browsers!
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else {
throw new Error("Your browser doesn't support the XMLHttpRequest object!");
return;
throw new Error('Your browser doesn\'t support the XMLHttpRequest object!');
}

// Set handler to process server's response
Expand All @@ -86,9 +87,9 @@


// Regular expressions
var regex = app.regex = {
window.app.regex = {
newline: /\r\n/,
space: /\s/,
weburl: re_weburl
weburl: reWebUrl
};
}(_, window));
Loading