<commit_before>/**
 * @jsx React.DOM
 */
var React = require('react');
var bus = require('../bus');

var url = require('url');

var Router = require('react-router');
var Link = Router.Link;

function canShow(items, className){
    if (!items.length) {
        className += ' hidden';
    }
    return className;
}

var ReleaseDetail = React.createClass({
    componentWillMount: function(){
        var cat = this.props.params.cat;
        this.props.release = this.props.data.findWhere({cat:cat});
        var data = this.props.release.toJSON();
        
        // fix for &#1042; style unicode entities
        var s = document.createElement('span');
        s.innerHTML = '' + data.album + ' - ' + data.artist + '  | ' + data.cat.toUpperCase();
        document.title = s.innerHTML;
    },
    componentDidMount: function(){
        window.scrollTo(0,0);
    },
    getDownloadLinks: function(){

        var sources = ["fma", "archiveorg", "scene_org", "clearbits", "sonicsquirrel", "soundshiva", "dogmazic", "archiveorg", "jamendo", "bandcamp", "soundcloud", "mixcloud", "lastfm", "itunes", "amazon", "googleplay", "spotify", "discogs", "rym", "musicbrainz"];
        var release = this.props.release.toJSON();

        var downloadLinks = sources.map(function(source){
            if (release[source]) {
                return <a href={release[source]} target="_blank"><img src={'/iconss/'+source+'.png'}/></a>;
            };
        });
        return downloadLinks;

    },

    buildLink: function(release){
        return (
            <Link className="mini-link" to={"/release/" + release.cat}>
                <img src={release.cover} title={release.artist + ' - ' + release.album} />
            </Link>);
    },
    getTags: function(tags){

        return tags.map(function(tag){
            return (<span className='tag fontawesome-tag'>{tag}</span>)
        });
        
    },
    getCountries: function(countries){
        return countries.map(function(country){
            var country = country.replace('.','');
            return (<img className="artist-country" title="" src={"/flags/_flag_" + country + ".png"} />);
        });
    },
    getRelatedLinks: function(data){
        var relatedRelease = this.props.data.getMayAlsoLike({
            tags: data.tags,
            artist: data.artist,
            ignore: data.cat
        });

        var links = relatedRelease.map(function(model){
            var data = model.toJSON();
            return this.buildLink(data);
        }.bind(this));

        return links;

    },
    getBySameArtist: function(data){
        var bySameArtist = this.props.data.getByArtist(data.artist, data.cat);

        var links = bySameArtist.map(function(model){
            var data = model.toJSON();
            return this.buildLink(data);
        }.bind(this));

        return links;
    },
    startPlaying: function(){
        // push this release to the playlist queue
        bus.emit('queue', this.props.data);
    },
    render: function(){

        var data = this.props.release.toJSON();
        var playable = data.tracks && data.tracks.length;
        var coverPath = url.parse(data.cover);
        var formattedDate = data.momented.format('MMMM Do, YYYY');

        var relatedLinks = this.getRelatedLinks(data);
        var bySameArtist = this.getBySameArtist(data);

        var tags = this.getTags(data.tags);
        var countries = this.getCountries(data.country);
        var downloadLinks = this.getDownloadLinks();

        data.cover = '/'+coverPath.path;

        return (
<div className="release-full"><commit_msg>fix player<commit_after>/**
 * @jsx React.DOM
 */
var React = require('react');
var bus = require('../bus');

var url = require('url');

var Router = require('react-router');
var Link = Router.Link;

function canShow(items, className){
    if (!items.length) {
        className += ' hidden';
    }
    return className;
}

var ReleaseDetail = React.createClass({
    componentWillMount: function(){
        var cat = this.props.params.cat;
        this.props.release = this.props.data.findWhere({cat:cat});
        var data = this.props.release.toJSON();
        
        // fix for &#1042; style unicode entities
        var s = document.createElement('span');
        s.innerHTML = '' + data.album + ' - ' + data.artist + '  | ' + data.cat.toUpperCase();
        document.title = s.innerHTML;
    },
    componentDidMount: function(){
        window.scrollTo(0,0);
    },
    getDownloadLinks: function(){

        var sources = ["fma", "archiveorg", "scene_org", "clearbits", "sonicsquirrel", "soundshiva", "dogmazic", "archiveorg", "jamendo", "bandcamp", "soundcloud", "mixcloud", "lastfm", "itunes", "amazon", "googleplay", "spotify", "discogs", "rym", "musicbrainz"];
        var release = this.props.release.toJSON();

        var downloadLinks = sources.map(function(source){
            if (release[source]) {
                return <a href={release[source]} target="_blank"><img src={'/iconss/'+source+'.png'}/></a>;
            };
        });
        return downloadLinks;

    },

    buildLink: function(release){
        return (
            <Link className="mini-link" to={"/release/" + release.cat}>
                <img src={release.cover} title={release.artist + ' - ' + release.album} />
            </Link>);
    },
    getTags: function(tags){

        return tags.map(function(tag){
            return (<span className='tag fontawesome-tag'>{tag}</span>)
        });
        
    },
    getCountries: function(countries){
        return countries.map(function(country){
            var country = country.replace('.','');
            return (<img className="artist-country" title="" src={"/flags/_flag_" + country + ".png"} />);
        });
    },
    getRelatedLinks: function(data){
        var relatedRelease = this.props.data.getMayAlsoLike({
            tags: data.tags,
            artist: data.artist,
            ignore: data.cat
        });

        var links = relatedRelease.map(function(model){
            var data = model.toJSON();
            return this.buildLink(data);
        }.bind(this));

        return links;

    },
    getBySameArtist: function(data){
        var bySameArtist = this.props.data.getByArtist(data.artist, data.cat);

        var links = bySameArtist.map(function(model){
            var data = model.toJSON();
            return this.buildLink(data);
        }.bind(this));

        return links;
    },
    startPlaying: function(){
        // push this release to the playlist queue
        bus.emit('queue', this.props.release);
    },
    render: function(){

        var data = this.props.release.toJSON();
        var playable = data.tracks && data.tracks.length;
        var coverPath = url.parse(data.cover);
        var formattedDate = data.momented.format('MMMM Do, YYYY');

        var relatedLinks = this.getRelatedLinks(data);
        var bySameArtist = this.getBySameArtist(data);

        var tags = this.getTags(data.tags);
        var countries = this.getCountries(data.country);
        var downloadLinks = this.getDownloadLinks();

        data.cover = '/'+coverPath.path;

        return (
<div className="release-full">
{'fraction_non_alphanumeric': 0.15542603386067166, 'fraction_numerical': 0.0016652789342214821, 'mean_word_length': 2.3899341486359362, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2339527', 'n_tokens_mistral': 2133, 'n_tokens_neox': 2064, 'n_words': 436}