<commit_before>define(['react', 'components/common/gravatar', 'router'], function(React, Gravatar, router) {

    var Rating = React.createClass({
        render: function() {
            var repeatString = function(string, num) {
                return new Array( num + 1 ).join( string );
            };
            return React.DOM.div({className: 'star-rating'}, 
                repeatString("\u2605", this.props.rating) + 
                repeatString("\u2606", 5 - this.props.rating));
        }
    });

    var Bookmark = React.createClass({
        getInitialState: function() {
            return {
                isFavorite: this.props.image.get('favorite')
            };
        },
        updateFavorite: function(model) {
            this.setState({'isFavorite': model.get('favorite')});
        },
        componentDidMount: function() {
            this.props.image.on('change:favorite', this.updateFavorite);
        },
        componentWillUnmount: function() {
            this.props.image.off('change:favorite', this.updateFavorite);
        },
        toggleFavorite: function(e) {
            e.preventDefault();
            this.props.image.set('favorite', !this.props.image.get('favorite'));
        },
        render: function() {
            return React.DOM.a({
                className: 'bookmark ' + (this.state.isFavorite ? 'on' : 'off'),
                href: '#',
                onClick: this.toggleFavorite
            });
        }
    });

    var ApplicationCard = React.createClass({
        getDefaultProps: function() {
            return {
                showDetails: true,
                showLaunch: false
            }
        },
        onImageClick: function(e) {
            e.preventDefault();
            router.navigate("images/" + this.props.application.id, {trigger: true});
        },
        render: function() {
            var app = this.props.application;

            var iconSize = 150;
            var icon;
            if (app.get('icon'))
                icon = React.DOM.img({
                    src: app.get('icon'),
                    width: iconSize,
                    height: iconSize
                });
            else
                icon = Gravatar({hash: app.get('uuid_hash'), size: iconSize});

            var imageUri = url_root + "images/" + app.get('uuid');

            return React.DOM.div({className: 'app-card'}, 
                React.DOM.div({className: 'icon-container'}, React.DOM.a({
                        href: imageUri, 
                        onClick: this.onImageClick
                    }, icon)),
                React.DOM.div({className: 'app-name'}, React.DOM.a({
                        href: imageUri, 
                        onClick: this.onImageClick,
                        title: app.get('name_or_id')
                    }, app.get('name_or_id'))),
                Rating({rating: app.get('rating')}),
                React.DOM.button({
                    className: 'btn btn-primary btn-block launch-button', 
                    onClick: this.props.onLaunch}, "Launch"),
                Bookmark({image: app}));
        }
    });

    var ApplicationCardList = React.createClass({<commit_msg>Fix image detail url<commit_after>define(['react', 'components/common/gravatar', 'router'], function(React, Gravatar, router) {

    var Rating = React.createClass({
        render: function() {
            var repeatString = function(string, num) {
                return new Array( num + 1 ).join( string );
            };
            return React.DOM.div({className: 'star-rating'}, 
                repeatString("\u2605", this.props.rating) + 
                repeatString("\u2606", 5 - this.props.rating));
        }
    });

    var Bookmark = React.createClass({
        getInitialState: function() {
            return {
                isFavorite: this.props.image.get('favorite')
            };
        },
        updateFavorite: function(model) {
            this.setState({'isFavorite': model.get('favorite')});
        },
        componentDidMount: function() {
            this.props.image.on('change:favorite', this.updateFavorite);
        },
        componentWillUnmount: function() {
            this.props.image.off('change:favorite', this.updateFavorite);
        },
        toggleFavorite: function(e) {
            e.preventDefault();
            this.props.image.set('favorite', !this.props.image.get('favorite'));
        },
        render: function() {
            return React.DOM.a({
                className: 'bookmark ' + (this.state.isFavorite ? 'on' : 'off'),
                href: '#',
                onClick: this.toggleFavorite
            });
        }
    });

    var ApplicationCard = React.createClass({
        getDefaultProps: function() {
            return {
                showDetails: true,
                showLaunch: false
            }
        },
        onImageClick: function(e) {
            e.preventDefault();
            router.navigate("images/" + this.props.application.id, {trigger: true});
        },
        render: function() {
            var app = this.props.application;

            var iconSize = 150;
            var icon;
            if (app.get('icon'))
                icon = React.DOM.img({
                    src: app.get('icon'),
                    width: iconSize,
                    height: iconSize
                });
            else
                icon = Gravatar({hash: app.get('uuid_hash'), size: iconSize});

            var imageUri = url_root + "/images/" + app.get('uuid');

            return React.DOM.div({className: 'app-card'}, 
                React.DOM.div({className: 'icon-container'}, React.DOM.a({
                        href: imageUri, 
                        onClick: this.onImageClick
                    }, icon)),
                React.DOM.div({className: 'app-name'}, React.DOM.a({
                        href: imageUri, 
                        onClick: this.onImageClick,
                        title: app.get('name_or_id')
                    }, app.get('name_or_id'))),
                Rating({rating: app.get('rating')}),
                React.DOM.button({
                    className: 'btn btn-primary btn-block launch-button', 
                    onClick: this.props.onLaunch}, "Launch"),
                Bookmark({image: app}));
        }
    });

    var ApplicationCardList = React.createClass({
{'fraction_non_alphanumeric': 0.134794776119403, 'fraction_numerical': 0.00404228855721393, 'mean_word_length': 1.473279507881584, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6639973', 'n_tokens_mistral': 1716, 'n_tokens_neox': 1635, 'n_words': 306}