<commit_before>var FormValidator;
(function ($, _, Backbone, Marionette) {
    FormValidator = {
        regex: {
            //RFC 2822
            email: /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,
            alpha: /^[a-zA-Z]+$/,
            alphanum: /^[a-zA-Z0-9]+$/
        },

        validate: function (validator, val, options) {
            if (_.isFunction(FormValidator[validator].evaluate)) return _(FormValidator[validator].evaluate).bind(this)(val, options);
            throw new Error('Validator does not exist : ' + validator);
        },

        /*     matches: function (val, field) {
         *//*jshint eqeqeq:false*//*
         return val == this.inputVal(field);
         },*/

        min: {
            id: '272b4a6f-055f-44af-bd2e-dc8d3f281537',
            evaluate: function (val, options) {
                if (val.length < options[0]) return false;
                return true;
            }
        },

        max: {
            id: 'c1bfaee0-7179-4764-a92a-42e1afb78b82',
            evaluate: function (val, options) {
                if (val.length > options[0]) return false;
                return true;
            }
        },

        numeric: {
            id: '85aee6f9-c7af-4658-b983-4be319e960c4',
            evaluate: function (val) {
                return !_.isNaN(val);
            }
        },

        alpha: {
            id: 'a355ed4d-6a00-44c9-8052-9361fb285ae5',
            evaluate: function (val) {
                return FormValidator.regex.alpha.test(val);
            }
        },

        alphanum: {
            id: '63f1cf8b-daed-48f2-a719-a2229de2fd94',
            evaluate: function (val) {
                return FormValidator.regex.alphanum.test(val);
            }
        },

        email: {
            id: '813dd3a8-c394-496b-a81c-93b97b4bbf87',
            evaluate: function (val) {
                return val === '' || FormValidator.regex.email.test(val);
            }
        },

        required: {
            id: 'c63eae79-f7b6-4747-88c0-2baa6bffe3e4',
            evaluate: function (val) {
                if (val === false || _.isNull(val) || _.isUndefined(val) || (_.isString(val) && val.length === 0)) return false;
                return true;
            }
        },

        boolean: {
            id: 'f23a85d8-389f-44db-bc1d-a9162c4a5580',
            evaluate: function (val) {
                return _.isBoolean(val);
            }
        }
    };
})(jQuery, _, Backbone, Marionette);<commit_msg>Changing to Marionette object<commit_after>var FormValidator;
(function ($, _, Backbone, Marionette) {
    FormValidator = Marionette.Object.extend({
        regex: {
            //RFC 2822
            email: /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,
            alpha: /^[a-zA-Z]+$/,
            alphanum: /^[a-zA-Z0-9]+$/
        },

        validate: function (validator, val, options) {
            if (_.isFunction(FormValidator[validator].evaluate)) return _(FormValidator[validator].evaluate).bind(this)(val, options);
            throw new Error('Validator does not exist : ' + validator);
        },

        /*     matches: function (val, field) {
         *//*jshint eqeqeq:false*//*
         return val == this.inputVal(field);
         },*/

        min: {
            id: '272b4a6f-055f-44af-bd2e-dc8d3f281537',
            evaluate: function (val, options) {
                if (val.length < options[0]) return false;
                return true;
            }
        },

        max: {
            id: 'c1bfaee0-7179-4764-a92a-42e1afb78b82',
            evaluate: function (val, options) {
                if (val.length > options[0]) return false;
                return true;
            }
        },

        numeric: {
            id: '85aee6f9-c7af-4658-b983-4be319e960c4',
            evaluate: function (val) {
                return !_.isNaN(val);
            }
        },

        alpha: {
            id: 'a355ed4d-6a00-44c9-8052-9361fb285ae5',
            evaluate: function (val) {
                return FormValidator.regex.alpha.test(val);
            }
        },

        alphanum: {
            id: '63f1cf8b-daed-48f2-a719-a2229de2fd94',
            evaluate: function (val) {
                return FormValidator.regex.alphanum.test(val);
            }
        },

        email: {
            id: '813dd3a8-c394-496b-a81c-93b97b4bbf87',
            evaluate: function (val) {
                return val === '' || FormValidator.regex.email.test(val);
            }
        },

        required: {
            id: 'c63eae79-f7b6-4747-88c0-2baa6bffe3e4',
            evaluate: function (val) {
                if (val === false || _.isNull(val) || _.isUndefined(val) || (_.isString(val) && val.length === 0)) return false;
                return true;
            }
        },

        boolean: {
            id: 'f23a85d8-389f-44db-bc1d-a9162c4a5580',
            evaluate: function (val) {
                return _.isBoolean(val);
            }
        }
    });
})(jQuery, _, Backbone, Marionette);
<|endoftext|>


<commit_before>var lastLookup = [];
var lastSearch = [];
var bool = [true];
var lastTerm = [];
var opts = {
    lines: 13, // The number of lines to draw
    length: 7, // The length of each line
    width: 4, // The line thickness
    radius: 10, // The radius of the inner circle
    corners: 1, // Corner roundness (0..1)
    rotate: 0, // The rotation offset
    color: '#000', // #rgb or #rrggbb
    speed: 1, // Rounds per second
    trail: 60, // Afterglow percentage
    shadow: false, // Whether to render a shadow
    hwaccel: false, // Whether to use hardware acceleration
    className: 'spinner', // The CSS class to assign to the spinner
    zIndex: 2e9, // The z-index (defaults to 2000000000)
    top: 'auto', // Top position relative to parent in px
    left: 'auto' // Left position relative to parent in px
};
/*
* Search the yelp api
*/
var searchYelp = function (term, near, category_filters, offset) {
    var target = document.getElementById('columnCenter');
    $('.columnCenter').empty();
    var spinner = new Spinner(opts).spin(target);
    var opt_int;
    var opt_cat;
    if (offset == undefined) {
        opt_int = 0;
    } else {
        opt_int = offset;
    }
    if (category_filters == undefined) {
        opt_cat = "";
    } else {
        opt_cat = category_filters;
    }
    if (near && term){
        searchQuery(term, near, opt_cat, opt_int);
    } else {
        if(bool[0]) {
            spinner.stop();
            bool = [];
            bool.push(false);
            $('#middle').append('
' +
                                '<button type="button" onclick="bool.pop(); bool.push(true);" class="close" data-dismiss="alert">×</button>'+
                                'Error! Please include the appropriate info in the appropriate fields.'+
                                '
');
        }
    }
};

/*
*
*/
var getBookmarks = function(term) {
    lastTerm.push(term);
    var bookmarks = searchFavorites(term);
    browseFavorites(bookmarks);
};

/*
* Browses Favorites
*/
var browseFavorites = function(data) {
    var current = $('.active1').text();
    if (current != 'Lookup'){
        lastLookup.push(data);
        $('.active1').remove();
        $('.columnCenter').empty();
        $('.breadcrumb').empty();
        $('.breadcrumb').append('
' + 'Home' + ' /
');
        $('.breadcrumb').append('
Lookup
 ');
        history.pushState({}, 'Yelptastic- Browse Favorite', '#bookmarksearch');
    }
    $('.columnCenter').empty();

    browseBookmarks(data, 0);
};

/*
* Displays the view for searching yelp.
*/
var addFavoritesView = function(data, total, opt_term, opt_location, opt_cat, opt_offset) {
    //$('.breadcrumbs').removeClass('.active');
    var current = $('.active1').text();
    $('.alert').remove();
    bool = [];
    bool.push(true);

    lastSearch.push(data);
    lastSearch.push(total);
    lastSearch.push(opt_term);
    lastSearch.push(opt_location);
    lastSearch.push(opt_cat);
    lastSearch.push(opt_offset);
    if (current != 'Search'){
        $('.active1').remove();
        $('.columnCenter').empty();
        $('.breadcrumb').empty();
        $('.breadcrumb').append('
' + 'Home' + ' /
');
        $('.breadcrumb').append('
Search
 ');
        history.pushState({}, 'Yelptastic- Yelp Search', '#yelpsearch');
    }
    $('.columnLeft').empty();
    $('.columnCenter').empty();

    var allcategories = $.getJSON("scripts/categories.json", function(y){
        parseYelpCategories(opt_term, opt_location, y);
    });

    addQuery(data, opt_offset, total, opt_term, opt_location, opt_cat);
};

/*
* Takes in the results and appends them to the thumbnails grids
*/
var addQuery = function (results, opt_int, opt_total, opt_term, opt_location, opt_cat) {
    var target = document.getElementById('columnCenter');
    var spinner = new Spinner(opts).stop(target);
    $('.columnCenter').empty();
    $thumbnailswrapper = $('

');
    var data = [];
    for (var i = 0; i < results.length; i ++) {
        var image_url;
        $button = $('<button>Favorite</button>');
        if(results[i].image_url) {
            image_url = results[i].image_url;
        } else {
            image_url = 'http://s3-media3.ak.yelpcdn.com/assets/2/www/img/305e17fe6ed8/gfx/blank_biz_medium_sq.png';
        }
        data.push({
            name:results[i].name,
            image:image_url,
            quote:results[i].snippet_text,
            ratingImage:results[i].rating_img_url,
            button:'Favorite',
            object:JSON.stringify(results[i]),
            url:results[i].url,
            phonenumber:results[i].display_phone,
            n:i.toString(),
            views:results[i].review_count,
            distance:results[i].distance,
            address:results[i].location.display_address[0] +" " + results[i].location.display_address[1]+" " + results[i].location.display_address[2]
        });
    }
    var source = $('#results').html();
    var template = Handlebars.compile(source);
    var string = template(data);
    $thumbnailswrapper.append(string);
    if (opt_total > 20) {
        $buttonRow = $('

');

        if (opt_int >= 20) {
            $see_prev = $('<input type="button" value="Previous 20" name="nextButton">');
            $see_prev.click(function() {
                searchYelp(opt_term, opt_location, opt_cat, opt_int-20);
            });
            $buttonRow.append($see_prev);
        }
        if (opt_int + 20 <= opt_total) {
            $see_all = $('<input type="button" value="Next 20" name="prevButton">');
            $see_all.click(function() {
                searchYelp(opt_term, opt_location, opt_cat, opt_int + 20);
            });
            $buttonRow.append($see_all);
        }
        $thumbnailswrapper.append($buttonRow);
    }
    $('.columnCenter').append($thumbnailswrapper);
    window.scroll();
};

/*
* Takes in the results and appends them to the thumbnails grids
*/
var browseBookmarks = function (results, opt_int) {
    $('.columnCenter').empty();
    $thumbnailswrapper = $('

');
    $buttonRow = $('

');
    var data = [];
    var image_url;
    if (results.length >=20) {
        for (var i = opt_int; i < opt_int + 20; i ++) {
            if(results[i].image_url) {
                image_url = results[i].image_url;
            } else {
                image_url = 'http://s3-media3.ak.yelpcdn.com/assets/2/www/img/305e17fe6ed8/gfx/blank_biz_medium_sq.png';
            }
            $button = $('<button>Favorite</button>');
            alert('results[i].location.display_address[0]');
            data.push({
                name:results[i].name,
                image:image_url,
                quote:results[i].snippet_text,
                ratingImage:results[i].rating_img_url,
                tags:results[i].tags,
                object:JSON.stringify(results[i]),
                url:results[i].url,
                notes:results[i].notes,
                views:results[i].review_count,
                distance:results[i].distance,
                address:results[i].location.display_address[0] +" " + results[i].location.display_address[1]+" "+ results[i].location.display_address[2]

            });
        }
    } else {
        for (var i = opt_int; i < results.length; i ++) {
            if(results[i].image_url) {
                image_url = results[i].image_url;
            } else {
                image_url = 'http://s3-media3.ak.yelpcdn.com/assets/2/www/img/305e17fe6ed8/gfx/blank_biz_medium_sq.png';
            }
            $button = $('<button>Favorite</button>');
            data.push({
                name:results[i].name,
                image:image_url,
                quote:results[i].snippet_text,
                ratingImage:results[i].rating_img_url,
                tags:results[i].tags,
                url:results[i].url,
                notes:results[i].notes,
                object:JSON.stringify(results[i]),
                views:results[i].review_count,
                distance:results[i].distance,
                address:results[i].location.display_address[0] +" " + results[i].location.display_address[1]+" " + results[i].location.display_address[2]
            });
        }
    }
    var source = $('#browse').html();
    var template = Handlebars.compile(source);
    var string = template(data);
    var accordsource = $('#filters').html();
    var accordtemplate = Handlebars.compile(accordsource);
    var accordstring = template({funcname:'filterfavorites', results:JSON.stringify(results)});
    $('.columnRight').append(accordstring);
    $thumbnailswrapper.append(string);
    if (data.length >= 20) {
        if (opt_int >= 20) {
            $see_prev = $('<input type="button" value="Previous" name="nextButton">');
            $see_prev.click(function() {
                addQuery(results, opt_int-1);
            });
            $buttonRow.append($see_prev);
        }
        if (opt_int + 20 <= data.length) {
            $see_all = $('<input type="button" value="Next" name="prevButton">');
            $see_all.click(function() {
                addQuery(results, opt_int + 20);
            });
            $buttonRow.append($see_all);
        }
    }
    $thumbnailswrapper.append($buttonRow);
    $('.columnCenter').append($thumbnailswrapper);
    $('#pop').popover();
};

/*
* Function to send the bookmarks to the backend
*/
var saveFavorite = function (jsonString, tags1, notes1) {
    var object1 = jsonString;
    saveBookmark(object1, tags1, notes1);
};

var parseYelpCategories = function (term, location, categories) {

    var categories_wrapper = '
';
    for (var i in categories)
    {
        var genCategory = i;
        var genCategoryTag = i;
        genCategoryTag = genCategoryTag.replace(/ /g, "_");
        genCategoryTag = genCategoryTag.replace(/&/g, "And");
        categories_wrapper = categories_wrapper + '
';
        categories_wrapper = categories_wrapper + '
';
        categories_wrapper = categories_wrapper + '';
        categories_wrapper = categories_wrapper + genCategory;
        categories_wrapper = categories_wrapper + '';
        categories_wrapper = categories_wrapper + '
';
        categories_wrapper = categories_wrapper + '
';
        categories_wrapper = categories_wrapper + '
';

        for (var j in categories[i])
        {
            var subCategory = j;
            var subCategoryTag = categories[i][j];
            if (typeof categories[i][j] != "string")
            {
                subCategoryTag = subCategory;
                subCategoryTag = subCategoryTag.replace(/ /g, "_");
                subCategoryTag = subCategoryTag.replace(/&/g, "And");
            }

            categories_wrapper = categories_wrapper + '
';
            categories_wrapper = categories_wrapper + '
';
            categories_wrapper = categories_wrapper + '';

            categories_wrapper = categories_wrapper + subCategory;
            categories_wrapper = categories_wrapper + '';
            categories_wrapper = categories_wrapper + '
';

            if (typeof categories[i][j] != "string")
            {
                categories_wrapper = categories_wrapper + '
';
                categories_wrapper = categories_wrapper + '
';

                for (var k in categories[i][j])
                {
                    var subSubCategory = k;
                    var subSubCategoryTag = categories[i][j][k];

                    categories_wrapper = categories_wrapper + '
';
                    categories_wrapper = categories_wrapper + '
';
                    categories_wrapper = categories_wrapper + '';
                    categories_wrapper = categories_wrapper + subSubCategory;
                    categories_wrapper = categories_wrapper + '';
                    categories_wrapper = categories_wrapper + '
';
                    categories_wrapper = categories_wrapper + '
';
                }

                categories_wrapper = categories_wrapper + '
';
                categories_wrapper = categories_wrapper + '
';
            }
            categories_wrapper = categories_wrapper + '
';
        }

        categories_wrapper = categories_wrapper + '
';
        categories_wrapper = categories_wrapper + '
';
        categories_wrapper = categories_wrapper + '
';
    }
    categories_wrapper = categories_wrapper + "
";
    console.log(categories_wrapper);
    $('.columnLeft').append(categories_wrapper);
};
<commit_msg>Make all ugly page buttons to better style buttons.<commit_after>var lastLookup = [];
var lastSearch = [];
var bool = [true];
var lastTerm = [];
var opts = {
    lines: 13, // The number of lines to draw
    length: 7, // The length of each line
    width: 4, // The line thickness
    radius: 10, // The radius of the inner circle
    corners: 1, // Corner roundness (0..1)
    rotate: 0, // The rotation offset
    color: '#000', // #rgb or #rrggbb
    speed: 1, // Rounds per second
    trail: 60, // Afterglow percentage
    shadow: false, // Whether to render a shadow
    hwaccel: false, // Whether to use hardware acceleration
    className: 'spinner', // The CSS class to assign to the spinner
    zIndex: 2e9, // The z-index (defaults to 2000000000)
    top: 'auto', // Top position relative to parent in px
    left: 'auto' // Left position relative to parent in px
};
/*
* Search the yelp api
*/
var searchYelp = function (term, near, category_filters, offset) {
    var target = document.getElementById('columnCenter');
    $('.columnCenter').empty();
    var spinner = new Spinner(opts).spin(target);
    var opt_int;
    var opt_cat;
    if (offset == undefined) {
        opt_int = 0;
    } else {
        opt_int = offset;
    }
    if (category_filters == undefined) {
        opt_cat = "";
    } else {
        opt_cat = category_filters;
    }
    if (near && term){
        searchQuery(term, near, opt_cat, opt_int);
    } else {
        if(bool[0]) {
            spinner.stop();
            bool = [];
            bool.push(false);
            $('#middle').append('
' +
                                '<button type="button" onclick="bool.pop(); bool.push(true);" class="close" data-dismiss="alert">×</button>'+
                                'Error! Please include the appropriate info in the appropriate fields.'+
                                '
');
        }
    }
};

/*
*
*/
var getBookmarks = function(term) {
    lastTerm.push(term);
    var bookmarks = searchFavorites(term);
    browseFavorites(bookmarks);
};

/*
* Browses Favorites
*/
var browseFavorites = function(data) {
    var current = $('.active1').text();
    if (current != 'Lookup'){
        lastLookup.push(data);
        $('.active1').remove();
        $('.columnCenter').empty();
        $('.breadcrumb').empty();
        $('.breadcrumb').append('
' + 'Home' + ' /
');
        $('.breadcrumb').append('
Lookup
 ');
        history.pushState({}, 'Yelptastic- Browse Favorite', '#bookmarksearch');
    }
    $('.columnCenter').empty();

    browseBookmarks(data, 0);
};

/*
* Displays the view for searching yelp.
*/
var addFavoritesView = function(data, total, opt_term, opt_location, opt_cat, opt_offset) {
    //$('.breadcrumbs').removeClass('.active');
    var current = $('.active1').text();
    $('.alert').remove();
    bool = [];
    bool.push(true);

    lastSearch.push(data);
    lastSearch.push(total);
    lastSearch.push(opt_term);
    lastSearch.push(opt_location);
    lastSearch.push(opt_cat);
    lastSearch.push(opt_offset);
    if (current != 'Search'){
        $('.active1').remove();
        $('.columnCenter').empty();
        $('.breadcrumb').empty();
        $('.breadcrumb').append('
' + 'Home' + ' /
');
        $('.breadcrumb').append('
Search
 ');
        history.pushState({}, 'Yelptastic- Yelp Search', '#yelpsearch');
    }
    $('.columnLeft').empty();
    $('.columnCenter').empty();

    var allcategories = $.getJSON("scripts/categories.json", function(y){
        parseYelpCategories(opt_term, opt_location, y);
    });

    addQuery(data, opt_offset, total, opt_term, opt_location, opt_cat);
};

/*
* Takes in the results and appends them to the thumbnails grids
*/
var addQuery = function (results, opt_int, opt_total, opt_term, opt_location, opt_cat) {
    var target = document.getElementById('columnCenter');
    var spinner = new Spinner(opts).stop(target);
    $('.columnCenter').empty();
    $thumbnailswrapper = $('

');
    var data = [];
    for (var i = 0; i < results.length; i ++) {
        var image_url;
        $button = $('<button>Favorite</button>');
        if(results[i].image_url) {
            image_url = results[i].image_url;
        } else {
            image_url = 'http://s3-media3.ak.yelpcdn.com/assets/2/www/img/305e17fe6ed8/gfx/blank_biz_medium_sq.png';
        }
        data.push({
            name:results[i].name,
            image:image_url,
            quote:results[i].snippet_text,
            ratingImage:results[i].rating_img_url,
            button:'Favorite',
            object:JSON.stringify(results[i]),
            url:results[i].url,
            phonenumber:results[i].display_phone,
            n:i.toString(),
            views:results[i].review_count,
            distance:results[i].distance,
            address:results[i].location.display_address[0] +" " + results[i].location.display_address[1]+" " + results[i].location.display_address[2]
        });
    }
    var source = $('#results').html();
    var template = Handlebars.compile(source);
    var string = template(data);
    $thumbnailswrapper.append(string);
    if (opt_total > 20) {
        $buttonRow = $('

');

        if (opt_int >= 20) {
            $see_prev = $('<button class="btn" value="Previous 20" name="nextButton">');
            $see_prev.click(function() {
                searchYelp(opt_term, opt_location, opt_cat, opt_int-20);
            });
            $buttonRow.append($see_prev);
        }
        if (opt_int + 20 <= opt_total) {
            $see_all = $('<button class="btn" value="Next 20" name="prevButton">');
            $see_all.click(function() {
                searchYelp(opt_term, opt_location, opt_cat, opt_int + 20);
            });
            $buttonRow.append($see_all);
        }
        $thumbnailswrapper.append($buttonRow);
    }
    $('.columnCenter').append($thumbnailswrapper);
    window.scroll();
};

/*
* Takes in the results and appends them to the thumbnails grids
*/
var browseBookmarks = function (results, opt_int) {
    $('.columnCenter').empty();
    $thumbnailswrapper = $('

');
    $buttonRow = $('

');
    var data = [];
    var image_url;
    if (results.length >=20) {
        for (var i = opt_int; i < opt_int + 20; i ++) {
            if(results[i].image_url) {
                image_url = results[i].image_url;
            } else {
                image_url = 'http://s3-media3.ak.yelpcdn.com/assets/2/www/img/305e17fe6ed8/gfx/blank_biz_medium_sq.png';
            }
            $button = $('<button>Favorite</button>');
            alert('results[i].location.display_address[0]');
            data.push({
                name:results[i].name,
                image:image_url,
                quote:results[i].snippet_text,
                ratingImage:results[i].rating_img_url,
                tags:results[i].tags,
                object:JSON.stringify(results[i]),
                url:results[i].url,
                notes:results[i].notes,
                views:results[i].review_count,
                distance:results[i].distance,
                address:results[i].location.display_address[0] +" " + results[i].location.display_address[1]+" "+ results[i].location.display_address[2]

            });
        }
    } else {
        for (var i = opt_int; i < results.length; i ++) {
            if(results[i].image_url) {
                image_url = results[i].image_url;
            } else {
                image_url = 'http://s3-media3.ak.yelpcdn.com/assets/2/www/img/305e17fe6ed8/gfx/blank_biz_medium_sq.png';
            }
            $button = $('<button>Favorite</button>');
            data.push({
                name:results[i].name,
                image:image_url,
                quote:results[i].snippet_text,
                ratingImage:results[i].rating_img_url,
                tags:results[i].tags,
                url:results[i].url,
                notes:results[i].notes,
                object:JSON.stringify(results[i]),
                views:results[i].review_count,
                distance:results[i].distance,
                address:results[i].location.display_address[0] +" " + results[i].location.display_address[1]+" " + results[i].location.display_address[2]
            });
        }
    }
    var source = $('#browse').html();
    var template = Handlebars.compile(source);
    var string = template(data);
    var accordsource = $('#filters').html();
    var accordtemplate = Handlebars.compile(accordsource);
    var accordstring = template({funcname:'filterfavorites', results:JSON.stringify(results)});
    $('.columnRight').append(accordstring);
    $thumbnailswrapper.append(string);
    if (data.length >= 20) {
        if (opt_int >= 20) {
            $see_prev = $('<button class="btn" value="Previous" name="nextButton">');
            $see_prev.click(function() {
                addQuery(results, opt_int-1);
            });
            $buttonRow.append($see_prev);
        }
        if (opt_int + 20 <= data.length) {
            $see_all = $('<button class="btn" value="Next" name="prevButton">');
            $see_all.click(function() {
                addQuery(results, opt_int + 20);
            });
            $buttonRow.append($see_all);
        }
    }
    $thumbnailswrapper.append($buttonRow);
    $('.columnCenter').append($thumbnailswrapper);
    $('#pop').popover();
};

/*
* Function to send the bookmarks to the backend
*/
var saveFavorite = function (jsonString, tags1, notes1) {
    var object1 = jsonString;
    saveBookmark(object1, tags1, notes1);
};

var parseYelpCategories = function (term, location, categories) {

    var categories_wrapper = '
';
    for (var i in categories)
    {
        var genCategory = i;
        var genCategoryTag = i;
        genCategoryTag = genCategoryTag.replace(/ /g, "_");
        genCategoryTag = genCategoryTag.replace(/&/g, "And");
        categories_wrapper = categories_wrapper + '
';
        categories_wrapper = categories_wrapper + '
';
        categories_wrapper = categories_wrapper + '';
        categories_wrapper = categories_wrapper + genCategory;
        categories_wrapper = categories_wrapper + '';
        categories_wrapper = categories_wrapper + '
';
        categories_wrapper = categories_wrapper + '
';
        categories_wrapper = categories_wrapper + '
';

        for (var j in categories[i])
        {
            var subCategory = j;
            var subCategoryTag = categories[i][j];
            if (typeof categories[i][j] != "string")
            {
                subCategoryTag = subCategory;
                subCategoryTag = subCategoryTag.replace(/ /g, "_");
                subCategoryTag = subCategoryTag.replace(/&/g, "And");
            }

            categories_wrapper = categories_wrapper + '
';
            categories_wrapper = categories_wrapper + '
';
            categories_wrapper = categories_wrapper + '';

            categories_wrapper = categories_wrapper + subCategory;
            categories_wrapper = categories_wrapper + '';
            categories_wrapper = categories_wrapper + '
';

            if (typeof categories[i][j] != "string")
            {
                categories_wrapper = categories_wrapper + '
';
                categories_wrapper = categories_wrapper + '
';

                for (var k in categories[i][j])
                {
                    var subSubCategory = k;
                    var subSubCategoryTag = categories[i][j][k];

                    categories_wrapper = categories_wrapper + '
';
                    categories_wrapper = categories_wrapper + '
';
                    categories_wrapper = categories_wrapper + '';
                    categories_wrapper = categories_wrapper + subSubCategory;
                    categories_wrapper = categories_wrapper + '';
                    categories_wrapper = categories_wrapper + '
';
                    categories_wrapper = categories_wrapper + '
';
                }

                categories_wrapper = categories_wrapper + '
';
                categories_wrapper = categories_wrapper + '
';
            }
            categories_wrapper = categories_wrapper + '
';
        }

        categories_wrapper = categories_wrapper + '
';
        categories_wrapper = categories_wrapper + '
';
        categories_wrapper = categories_wrapper + '
';
    }
    categories_wrapper = categories_wrapper + "
";
    console.log(categories_wrapper);
    $('.columnLeft').append(categories_wrapper);
};
<|endoftext|>


<commit_before>'use strict';

var //---------------
    //    Imports
    //---------------

    path = require('path'),
    q = require('mercenary/promises').q,
    lang = require('mercenary/lang'),
    partial = lang.partial,
    destructured = lang.destructured,
    has = lang.has,
    each = lang.each,
    extend = lang.extend,
    items = lang.items,
    get = lang.get,
    isUndefined = lang.is.undef,

    //----------------------
    //    Implementation
    //----------------------

    // A map from settings module file paths to formidable instances.
    cache = {},

    // The default formidable settings module file path.
    defaultPath = process.env.FORMIDABLE_SETTINGS_MODULE,

    // Reset the require() cache for formidable and for any paths resolved with the path library.
    reset = function() {
        var path = cache[defaultPath] && cache[defaultPath].path;

        delete require.cache[path.join(__dirname, 'formidable.js')];
        if (path) {
            path.js.clear();
            path.template.clear();
        }
    },

    // Configure the default settings module file path.
    configure = function(settingsPath) {
        reset();
        defaultPath = path.resolve(settingsPath);
        return {
            load: partial(load, defaultPath)
        };
    },

    // Load the formidable instance identified by the settings module file path.
    // Optionally accepts a settings object as the second parameter, which
    // will be used instead of an on-disk module to instantiate the formidable
    // instance. For the latter case, the settings path serves as a key for the
    // formidable instance in subsequent calls to load().
    load = function(settingsPath, settings) {
        var normalPath = (
                (settingsPath || defaultPath) &&
                path.resolve(settingsPath || defaultPath));

        if (isUndefined(normalPath)) {
            throw new Error(
                'Either the FORMIDABLE_SETTINGS_MODULE environment variable ' +
                'must be set to the settings module file path, or a path ' +
                'must be passed to formidable/settings.load()');
        }
        if (has(cache, normalPath) && settings) {
            throw new Error(
                'A formidable instance for the settings module file path "' +
                normalPath +
                '" already exists, so a new instance for the given settings ' +
                'cannot be created.');
        }
        return (
            cache[normalPath] ||
            instantiate(
                normalPath,
                settings || require(normalPath)));
    },

    // Instantiate and cache a formidable instance from the given options.
    instantiate = function(id, options) {
        var option = partial(get, options),
            log = require('./lib/log')(option),
            path = require('./lib/path')(option),
            context = require('./lib/context')(option),
            api = require('./lib/api')(option),
            middleware = require('./lib/middleware')(option),
            urls = require('./lib/urls')(option, path),
            template = require('./lib/templating/' + (option('templating') || 'swig'))(option, path, urls),
            plugins = option('plugins') || [],
            build = (
                extend(
                    require('./lib/build')(option, log, path, context, middleware, urls, template),
                    {
                        q: q,
                        log: log,
                        path: path,
                        context: context,
                        api: api,
                        middleware: middleware,
                        urls: urls,
                        template: template,
                        option: option
                    }));

        // Debug?
        if (option('debug')) {
            q.longStackSupport = true;
        }

        // Cache the build API so that it's immediately available for import
        // with require('formidable').
        cache[id] = build;

        // Load any plugins.
        each(items(plugins), destructured(function(name, options) {
            path.js.require(name)(build, partial(get, options));
        }));

        return build;
    };

//------------------
//    Public API
//------------------

module.exports = {
    reset: reset,
    configure: configure,
    load: load
};
<commit_msg>Fixed name conflict bug in settings.js<commit_after>'use strict';

var //---------------
    //    Imports
    //---------------

    path = require('path'),
    q = require('mercenary/promises').q,
    lang = require('mercenary/lang'),
    partial = lang.partial,
    destructured = lang.destructured,
    has = lang.has,
    each = lang.each,
    extend = lang.extend,
    items = lang.items,
    get = lang.get,
    isUndefined = lang.is.undef,

    //----------------------
    //    Implementation
    //----------------------

    // A map from settings module file paths to formidable instances.
    cache = {},

    // The default formidable settings module file path.
    defaultPath = process.env.FORMIDABLE_SETTINGS_MODULE,

    // Reset the require() cache for formidable and for any paths resolved with the path library.
    reset = function() {
        var cached = cache[defaultPath] && cache[defaultPath].path;

        delete require.cache[path.join(__dirname, 'formidable.js')];
        if (cached) {
            cached.js.clear();
            cached.template.clear();
        }
    },

    // Configure the default settings module file path.
    configure = function(settingsPath) {
        reset();
        defaultPath = path.resolve(settingsPath);
        return {
            load: partial(load, defaultPath)
        };
    },

    // Load the formidable instance identified by the settings module file path.
    // Optionally accepts a settings object as the second parameter, which
    // will be used instead of an on-disk module to instantiate the formidable
    // instance. For the latter case, the settings path serves as a key for the
    // formidable instance in subsequent calls to load().
    load = function(settingsPath, settings) {
        var normalPath = (
                (settingsPath || defaultPath) &&
                path.resolve(settingsPath || defaultPath));

        if (isUndefined(normalPath)) {
            throw new Error(
                'Either the FORMIDABLE_SETTINGS_MODULE environment variable ' +
                'must be set to the settings module file path, or a path ' +
                'must be passed to formidable/settings.load()');
        }
        if (has(cache, normalPath) && settings) {
            throw new Error(
                'A formidable instance for the settings module file path "' +
                normalPath +
                '" already exists, so a new instance for the given settings ' +
                'cannot be created.');
        }
        return (
            cache[normalPath] ||
            instantiate(
                normalPath,
                settings || require(normalPath)));
    },

    // Instantiate and cache a formidable instance from the given options.
    instantiate = function(id, options) {
        var option = partial(get, options),
            log = require('./lib/log')(option),
            path = require('./lib/path')(option),
            context = require('./lib/context')(option),
            api = require('./lib/api')(option),
            middleware = require('./lib/middleware')(option),
            urls = require('./lib/urls')(option, path),
            template = require('./lib/templating/' + (option('templating') || 'swig'))(option, path, urls),
            plugins = option('plugins') || [],
            build = (
                extend(
                    require('./lib/build')(option, log, path, context, middleware, urls, template),
                    {
                        q: q,
                        log: log,
                        path: path,
                        context: context,
                        api: api,
                        middleware: middleware,
                        urls: urls,
                        template: template,
                        option: option
                    }));

        // Debug?
        if (option('debug')) {
            q.longStackSupport = true;
        }

        // Cache the build API so that it's immediately available for import
        // with require('formidable').
        cache[id] = build;

        // Load any plugins.
        each(items(plugins), destructured(function(name, options) {
            path.js.require(name)(build, partial(get, options));
        }));

        return build;
    };

//------------------
//    Public API
//------------------

module.exports = {
    reset: reset,
    configure: configure,
    load: load
};
<|endoftext|>


<commit_before>document.addEventListener('DOMContentLoaded', function(){
  var dkcb = document.getElementById('dkcb');
  var kw = document.getElementById('kw');

  // set the initial state of the checkbox
  console.log(localStorage["dekardashianize"]);
  dkcb.checked = JSON.parse(localStorage["dekardashianize"]);
  kw.value = JSON.parse(localStorage["dekardashianizer_keywords"]);

  dkcb.addEventListener("change", function(){
    console.log("checkbox changed to "+dkcb.checked);
    localStorage["dekardashianize"] = JSON.stringify(dkcb.checked);
   });

  kw.addEventListener("keyup", function(){ // we save on keyup here since we're not guaranteed to get a change event on a textarea
    console.log("Keywords changed to"+kw.value);
    Keywords = kw.value.split(",");
    for (var j=0; j<Keywords.length; j++){ // trim the user's inputs
      Keywords[j]=Keywords[j].trim();
    }
    console.log(typeof(Keywords));
    localStorage["dekardashianizer_keywords"]=JSON.stringify(Keywords);
  });
});
<commit_msg>Removed some logging<commit_after>document.addEventListener('DOMContentLoaded', function(){
  var dkcb = document.getElementById('dkcb');
  var kw = document.getElementById('kw');

  // set the initial state of the checkbox
  console.log(localStorage["dekardashianize"]);
  dkcb.checked = JSON.parse(localStorage["dekardashianize"]);
  kw.value = JSON.parse(localStorage["dekardashianizer_keywords"]);

  dkcb.addEventListener("change", function(){
    console.log("checkbox changed to "+dkcb.checked);
    localStorage["dekardashianize"] = JSON.stringify(dkcb.checked);
   });

  kw.addEventListener("keyup", function(){ // we save on keyup here since we're not guaranteed to get a change event on a textarea
    console.log("Keywords changed to"+kw.value);
    Keywords = kw.value.split(","); // this converts the string in the textarea back to a matrix
    for (var j=0; j<Keywords.length; j++){ // trim the user's inputs
      Keywords[j]=Keywords[j].trim();
    }
    localStorage["dekardashianizer_keywords"]=JSON.stringify(Keywords);
  });
});
<|endoftext|>


<commit_before>/**
 * IoSL-INav middleware/authenticate
 * SNET TU Berlin
 * using PIazza code base
 *
 * Uses Keycloak for authentication, finds or creates
 * a user and sets request.user.
 */

var User = require('../models/user');
var userController = require('../controllers/users');

/**
 * This function is called on login.
 * It either creates a user and adds a default
 * friends group (first login) or simply retrieves
 * the user.
 * This means: After logging in every user in our
 * system has a default group.
 */
var findOrCreateUser = function(req, res, next) {
  var userID = req.kauth.grant.id_token.content.sub;
  var name = req.kauth.grant.id_token.content.preferred_username;
  var email = req.kauth.grant.id_token.content.email;

  User.findById(userID, function(err, user) {

    if (err) {
      console.log("Error while locating model for userID: %s.", userID);
      console.log(err);
      res.status(500).json();
      return next();
    }

    if (user == null) {

      User.create({
        _id: userID,
        name: name,
        email: email,
        groups: [{
          name: 'All friends',
          members: []
        }]
      }, function(err, user) {

        if (err) {
          console.log("Could not login user with ID: %s.", userID);
          console.log(err);
          res.status(500).json();
          return next();
        }

        req.user = user;
        return next();
      });
    } else {

      /* Hotfix for mail retrieving problem. */
      req.user.email = email;
      req.user.save();

      User.findById(userID, function(err, user) {
        req.user = user;
        return next();
      });
    }
  }).populate('groups.members', 'name _id');
};

module.exports = function(keycloak) {
  return [
    keycloak.protect(),
    findOrCreateUser
  ]
};<commit_msg>Hopefully fixes issue from last commit.<commit_after>/**
 * IoSL-INav middleware/authenticate
 * SNET TU Berlin
 * using PIazza code base
 *
 * Uses Keycloak for authentication, finds or creates
 * a user and sets request.user.
 */

var User = require('../models/user');
var userController = require('../controllers/users');

/**
 * This function is called on login.
 * It either creates a user and adds a default
 * friends group (first login) or simply retrieves
 * the user.
 * This means: After logging in every user in our
 * system has a default group.
 */
var findOrCreateUser = function(req, res, next) {
  var userID = req.kauth.grant.id_token.content.sub;
  var name = req.kauth.grant.id_token.content.preferred_username;
  var email = req.kauth.grant.id_token.content.email;

  User.findById(userID, function(err, user) {

    if (err) {
      console.log("Error while locating model for userID: %s.", userID);
      console.log(err);
      res.status(500).json();
      return next();
    }

    if (user == null) {

      User.create({
        _id: userID,
        name: name,
        email: email,
        groups: [{
          name: 'All friends',
          members: []
        }]
      }, function(err, user) {

        if (err) {
          console.log("Could not login user with ID: %s.", userID);
          console.log(err);
          res.status(500).json();
          return next();
        }

        req.user = user;
        return next();
      });
    } else {

      /* Hotfix for mail retrieving problem. */
      user.email = email;
      user.save();

      User.findById(userID, function(err, user) {
        req.user = user;
        return next();
      });
    }
  }).populate('groups.members', 'name _id');
};

module.exports = function(keycloak) {
  return [
    keycloak.protect(),
    findOrCreateUser
  ]
};<|endoftext|>


<commit_before>var view = require('../../lib/view');
var auth = require('../../lib/auth');

module.exports = view.extend({
    id: 'sign-up',
    template: require('./index.html'),
    data: {
        // for navbar
        cancel: true,
        title: 'Sign up',
        user: {
            mailingList: true
        },
        login: auth.login,
    },
    methods: {
        onDone: function () {
            var self = this;
            if (!self.$data.user.username) {
                return;
            }
            if (!self.$data.user.terms) {
                return;
            }

            auth.createUser({
                assertion: auth._assertion,
                user: {
                    username: self.$data.user.username,
                    mailingList: self.$data.user.mailingList
                }
            }, function () {
                console.log('done!');
            });

        },
        checkUsernameExists: function() {
        var self = this;
        if(!self.$data.user.username)
            return;

        response = auth.post('/check-username', JSON.parse('{"username": "'+ self.$data.user.username +'"}'));
        if(response.exists)
            console.log("Username already exists");

        }
    },
    created: function () {
        var self = this;
        self.$data.email = auth._email;
        auth.on('newuser', function (assertion, email) {
            self.$data.email = email;
        });
    }
});
<commit_msg>Now successfully checks if usename is taken. Needs visual display. Currently prints result in console.<commit_after>var view = require('../../lib/view');
var auth = require('../../lib/auth');

module.exports = view.extend({
    id: 'sign-up',
    template: require('./index.html'),
    data: {
        // for navbar
        cancel: true,
        title: 'Sign up',
        user: {
            mailingList: true
        },
        login: auth.login,
    },
    methods: {
        onDone: function () {
            var self = this;
            if (!self.$data.user.username) {
                return;
            }
            if (!self.$data.user.terms) {
                return;
            }

            auth.createUser({
                assertion: auth._assertion,
                user: {
                    username: self.$data.user.username,
                    mailingList: self.$data.user.mailingList
                }
            }, function () {
                console.log('done!');
            });

        },
        checkUsernameExists: function() {
        var self = this;

        if(!self.$data.user.username)
            return;

        auth.checkUsername(self.$data.user.username, function(error, message){
            console.log("Finished checking for username: " + message);
        });

        }
    },
    created: function () {
        var self = this;
        self.$data.email = auth._email;
        auth.on('newuser', function (assertion, email) {
            self.$data.email = email;
        });
    }
});
<|endoftext|>


<commit_before>/**
 * Copyright (c) 2017-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

const React = require('react')

const CompLibrary = require('../../core/CompLibrary.js')
// const MarkdownBlock = CompLibrary.MarkdownBlock; /* Used to read markdown */
// const Container = CompLibrary.Container;
// const GridBlock = CompLibrary.GridBlock;
//
// const translate = require('../../server/translate.js').translate;

const translation = require('../../server/translation.js') // eslint-disable-line import/no-unresolved
const {
  Container,
  GridBlock,
  MarkdownBlock
} = require('../../core/CompLibrary') // eslint-disable-line import/no-unresolved
const { translate } = require('../../server/translate') // eslint-disable-line import/no-unresolved

const siteConfig = require(process.cwd() + '/siteConfig.js')

function imgUrl(img) {
  return siteConfig.baseUrl + 'img/' + img
}

function docUrl(doc, language) {
  return siteConfig.baseUrl + 'docs/' + (language ? language + '/' : '') + doc
}

function pageUrl(page, language) {
  return siteConfig.baseUrl + (language ? language + '/' : '') + page
}

class Button extends React.Component {
  render() {
    return (

          {this.props.children}

    )
  }
}

Button.defaultProps = {
  target: '_self'
}

const SplashContainer = props => (

{props.children}

)

const Logo = props => (

)

const ProjectTitle = props => (

    {siteConfig.title}
    {siteConfig.tagline}

)

const PromoSection = props => (

{props.children}

)

class HomeSplash extends React.Component {
  render() {
    let language = this.props.language || ''
    return (
      <SplashContainer>

          {/* <Logo img_src={imgUrl('rest-hapi-logo-alt.png')} /> */}
          <ProjectTitle />
          <PromoSection>
            <Button href="#try">Try It Out</Button>
            <Button href={docUrl('quick-start.html', language)}>
              Get Started
            </Button>
          </PromoSection>

            Star

      </SplashContainer>
    )
  }
}

const Block = props => (
  <Container
    padding={['bottom', 'top']}
    id={props.id}
    background={props.background}>
    <GridBlock align="center" contents={props.children} layout={props.layout} />
  </Container>
)

const Features = props => (
  <Block layout="fourColumn">
    {[
      {
        content:
          'Customize endpoints with configuration based features and hapi plugins.',
        image: imgUrl('flexible_icon.png'),
        imageAlign: 'top',
        title: 'Flexible'
      },
      {
        content:
          'Relational structure built into NoSQL documents based on mongoose schemas.',
        image: imgUrl('powerful_icon.png'),
        imageAlign: 'top',
        title: 'Powerful'
      },
      {
        content:
          'Less time with boilerplate functionality and more time building awesome APIs!',
        image: imgUrl('efficient_icon.png'),
        imageAlign: 'top',
        title: 'Efficient'
      }
    ]}
  </Block>
)

const FeatureCallout = props => (

What does it do?

    <MarkdownBlock>
      rest-hapi uses mongoose schemas to generate
      [CRUD](docs/creating-endpoints.html) and
      [association](docs/associations.html) REST API endpoints. Generating the
      endpoints allows for a rich set of [configurable](docs/configuration.html)
      features such as:
    </MarkdownBlock>

)

const FeaturesList = props => (
  <Block background="light">
    {[
      {
        content: `
- [Middleware](docs/middleware.html) support
- Query parameter, header, payload, and response [validation](docs/validation.html) using [joi](https://github.com/hapijs/joi)
- Route-level and document-level [authorization](docs/authorization.html)
- [Swagger docs](docs/swagger-documentation.html) via [hapi-swagger](https://github.com/glennjones/hapi-swagger)
- [Query parameter](docs/querying.html) support for searching, sorting, filtering, pagination, and [embedding of associated models](docs/querying.html#populate-nested-associations)
- Endpoint activity history through [Audit Logs](docs/audit-logs.html)
- Support for [policies](docs/policies.html) via [mrhorse](https://github.com/mark-bradshaw/mrhorse)
- [Duplicate fields](docs/duplicate-fields.html)
- Support for ["soft" delete](docs/soft-delete.html)
- Optional [metadata](docs/metadata.html)
`,
        image: imgUrl('docusaurus.svg'),
        imageAlign: 'right',
        title: 'Learn How'
      }
    ]}
  </Block>
)

const sh = (...args) => `~~~sh\n${String.raw(...args)}\n~~~`

const Querying = props => {
  return (
    <Container padding={['bottom', 'top']} background="light">

                    Querying

                <MarkdownBlock>
                  Search, sort, filter, paginate, and [embed associated
                  data](docs/querying.html#populate-nested-associations).
                </MarkdownBlock>

                  <MarkdownBlock>{sh`http get :8080/user \$limit==2 \$sort==email \$embed==role`}</MarkdownBlock>

    </Container>
  )
}

const Validation = props => {
  return (
    <Container padding={['bottom', 'top']} background="dark">

                    Validation

                <MarkdownBlock>
                  Query parameter, header, payload, and response
                  [validation](docs/validation.html) using
                  [joi](https://github.com/hapijs/joi).
                </MarkdownBlock>

    </Container>
  )
}

const Swagger = props => {
  return (
    <Container padding={['bottom', 'top']} background="light">

                    Swagger

                <MarkdownBlock>
                  [Swagger docs](docs/swagger-documentation.html) provide a UI
                  for your endpoints so you can easily interact with your data.
                </MarkdownBlock>

    </Container>
  )
}

const TryOut = props => {
  return (
    <Container
      padding={['bottom', 'top']}
      background="dark"
      align={'center'}
      id="try">

{'Try it out!'}

        <MarkdownBlock>
          Check out the [demo
          project](https://github.com/JKHeadley/rest-hapi-demo) or click the
          button below to play with the live demo.
        </MarkdownBlock>
        {/*
Check out the live demo or
 */}

          LIVE DEMO

    </Container>
  )
}

const Showcase = props => {
  if ((siteConfig.users || []).length === 0) {
    return null
  }
  const showcase = siteConfig.users
    .filter(user => {
      return user.pinned
    })
    .map((user, i) => {
      return (

      )
    })

  return (

{"Who's Using rest-hapi?"}

rest-hapi is powering the APIs of these projects...

{showcase}

          More {siteConfig.title} Users

  )
}

class Index extends React.Component {
  render() {
    let language = this.props.language || ''

    return (

        <HomeSplash language={language} />

          <Features />
          <FeatureCallout />
          {/* <FeaturesList /> */}
          <Querying />
          <Validation />
          <Swagger />
          <TryOut />
          <Showcase language={language} />

    )
  }
}

module.exports = Index
<commit_msg>- Added links for images<commit_after>/**
 * Copyright (c) 2017-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

const React = require('react')

const CompLibrary = require('../../core/CompLibrary.js')
// const MarkdownBlock = CompLibrary.MarkdownBlock; /* Used to read markdown */
// const Container = CompLibrary.Container;
// const GridBlock = CompLibrary.GridBlock;
//
// const translate = require('../../server/translate.js').translate;

const translation = require('../../server/translation.js') // eslint-disable-line import/no-unresolved
const {
  Container,
  GridBlock,
  MarkdownBlock
} = require('../../core/CompLibrary') // eslint-disable-line import/no-unresolved
const { translate } = require('../../server/translate') // eslint-disable-line import/no-unresolved

const siteConfig = require(process.cwd() + '/siteConfig.js')

function imgUrl(img) {
  return siteConfig.baseUrl + 'img/' + img
}

function docUrl(doc, language) {
  return siteConfig.baseUrl + 'docs/' + (language ? language + '/' : '') + doc
}

function pageUrl(page, language) {
  return siteConfig.baseUrl + (language ? language + '/' : '') + page
}

class Button extends React.Component {
  render() {
    return (

          {this.props.children}

    )
  }
}

Button.defaultProps = {
  target: '_self'
}

const SplashContainer = props => (

{props.children}

)

const Logo = props => (

)

const ProjectTitle = props => (

    {siteConfig.title}
    {siteConfig.tagline}

)

const PromoSection = props => (

{props.children}

)

class HomeSplash extends React.Component {
  render() {
    let language = this.props.language || ''
    return (
      <SplashContainer>

          {/* <Logo img_src={imgUrl('rest-hapi-logo-alt.png')} /> */}
          <ProjectTitle />
          <PromoSection>
            <Button href="#try">Try It Out</Button>
            <Button href={docUrl('quick-start.html', language)}>
              Get Started
            </Button>
          </PromoSection>

            Star

      </SplashContainer>
    )
  }
}

const Block = props => (
  <Container
    padding={['bottom', 'top']}
    id={props.id}
    background={props.background}>
    <GridBlock align="center" contents={props.children} layout={props.layout} />
  </Container>
)

const Features = props => (
  <Block layout="fourColumn">
    {[
      {
        content:
          'Customize endpoints with configuration based features and hapi plugins.',
        image: imgUrl('flexible_icon.png'),
        imageAlign: 'top',
        title: 'Flexible'
      },
      {
        content:
          'Relational structure built into NoSQL documents based on mongoose schemas.',
        image: imgUrl('powerful_icon.png'),
        imageAlign: 'top',
        title: 'Powerful'
      },
      {
        content:
          'Less time with boilerplate functionality and more time building awesome APIs!',
        image: imgUrl('efficient_icon.png'),
        imageAlign: 'top',
        title: 'Efficient'
      }
    ]}
  </Block>
)

const FeatureCallout = props => (

What does it do?

    <MarkdownBlock>
      rest-hapi uses mongoose schemas to generate
      [CRUD](docs/creating-endpoints.html) and
      [association](docs/associations.html) REST API endpoints. Generating the
      endpoints allows for a rich set of [configurable](docs/configuration.html)
      features such as:
    </MarkdownBlock>

)

const FeaturesList = props => (
  <Block background="light">
    {[
      {
        content: `
- [Middleware](docs/middleware.html) support
- Query parameter, header, payload, and response [validation](docs/validation.html) using [joi](https://github.com/hapijs/joi)
- Route-level and document-level [authorization](docs/authorization.html)
- [Swagger docs](docs/swagger-documentation.html) via [hapi-swagger](https://github.com/glennjones/hapi-swagger)
- [Query parameter](docs/querying.html) support for searching, sorting, filtering, pagination, and [embedding of associated models](docs/querying.html#populate-nested-associations)
- Endpoint activity history through [Audit Logs](docs/audit-logs.html)
- Support for [policies](docs/policies.html) via [mrhorse](https://github.com/mark-bradshaw/mrhorse)
- [Duplicate fields](docs/duplicate-fields.html)
- Support for ["soft" delete](docs/soft-delete.html)
- Optional [metadata](docs/metadata.html)
`,
        image: imgUrl('docusaurus.svg'),
        imageAlign: 'right',
        title: 'Learn How'
      }
    ]}
  </Block>
)

const sh = (...args) => `~~~sh\n${String.raw(...args)}\n~~~`

const Querying = props => {
  return (
    <Container padding={['bottom', 'top']} background="light">

                    Querying

                <MarkdownBlock>
                  Search, sort, filter, paginate, and [embed associated
                  data](docs/querying.html#populate-nested-associations).
                </MarkdownBlock>

                  <MarkdownBlock>{sh`http get :8080/user \$limit==2 \$sort==email \$embed==role`}</MarkdownBlock>

    </Container>
  )
}

const Validation = props => {
  return (
    <Container padding={['bottom', 'top']} background="dark">

                    Validation

                <MarkdownBlock>
                  Query parameter, header, payload, and response
                  [validation](docs/validation.html) using
                  [joi](https://github.com/hapijs/joi).
                </MarkdownBlock>

    </Container>
  )
}

const Swagger = props => {
  return (
    <Container padding={['bottom', 'top']} background="light">

                    Swagger

                <MarkdownBlock>
                  [Swagger docs](docs/swagger-documentation.html) provide a UI
                  for your endpoints so you can easily interact with your data.
                </MarkdownBlock>

    </Container>
  )
}

const TryOut = props => {
  return (
    <Container
      padding={['bottom', 'top']}
      background="dark"
      align={'center'}
      id="try">

{'Try it out!'}

        <MarkdownBlock>
          Check out the [demo
          project](https://github.com/JKHeadley/rest-hapi-demo) or click the
          button below to play with the live demo.
        </MarkdownBlock>
        {/*
Check out the live demo or
 */}

          LIVE DEMO

    </Container>
  )
}

const Showcase = props => {
  if ((siteConfig.users || []).length === 0) {
    return null
  }
  const showcase = siteConfig.users
    .filter(user => {
      return user.pinned
    })
    .map((user, i) => {
      return (

      )
    })

  return (

{"Who's Using rest-hapi?"}

rest-hapi is powering the APIs of these projects...

{showcase}

          More {siteConfig.title} Users

  )
}

class Index extends React.Component {
  render() {
    let language = this.props.language || ''

    return (

        <HomeSplash language={language} />

          <Features />
          <FeatureCallout />
          {/* <FeaturesList /> */}
          <Querying />
          <Validation />
          <Swagger />
          <TryOut />
          <Showcase language={language} />

    )
  }
}

module.exports = Index
<|endoftext|>


<commit_before>/**
 * Copyright (c) 2017-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

const React = require('react');

const CompLibrary = require('../../core/CompLibrary.js');

const MarkdownBlock = CompLibrary.MarkdownBlock; /* Used to read markdown */
const Container = CompLibrary.Container;
const GridBlock = CompLibrary.GridBlock;

const siteConfig = require(`${process.cwd()}/siteConfig.js`);

function imgUrl(img) {
  return `${siteConfig.baseUrl}img/${img}`;
}

function docUrl(doc, language) {
  return `${siteConfig.baseUrl}docs/${language ? `${language}/` : ''}${doc}`;
}

function pageUrl(page, language) {
  return siteConfig.baseUrl + (language ? `${language}/` : '') + page;
}

const Button = ({className = '', href, target, children}) => (

      {children}

);

Button.defaultProps = {
  target: '_self',
};

const SplashContainer = props => (

{props.children}

);

const Logo = props => (

);

const LogoSvg = ({style}) => (
  <svg style={style} viewBox="0 0 200 60" xmlns="http://www.w3.org/2000/svg">
    <g transform="translate(280.822 -299.303)">
      <text
        style={{
          lineHeight: "0%",
          InkscapeFontSpecification: "'Ubuntu, Medium'",
          textAlign: "start",
        }}
        fontFamily="Ubuntu"
        x="-227.697"
        y="343.108"
      >
        <tspan
          style={{
            lineHeight: "100%",
            InkscapeFontSpecification: "'Ubuntu, Medium'",
            textAlign: "start",
          }}
          fontSize="37.5"
          x="-227.697"
          y="343.108"
        >
          Unleash
        </tspan>
      </text>
      <rect
        height="22.483"
        width="40.186"
        fill="#0b1700"
        rx="9.74"
        x="-272.312"
        y="318.151"
      />
      <rect
        height="12.604"
        width="14.489"
        fill="#fff"
        rx="4.135"
        x="-251.511"
        y="323.352"
      />
    </g>
  </svg>
);

const ProjectTitle = () => (

    {siteConfig.tagline}

);

const PromoSection = props => (

{props.children}

);

class HomeSplash extends React.Component {
  render() {
    const language = this.props.language || '';
    return (
      <SplashContainer>

          <Survey />
          <ProjectTitle />

              Star

          <FeatureCallout />
          <PromoSection>
            <Button className="primary" href={docUrl('getting_started.html', language)}>Getting Started</Button>
            <Button href="#try">Try It Out</Button>
            <Button href={siteConfig.repoUrl}>GitHub</Button>
          </PromoSection>

          <SASSOffering />

      </SplashContainer>
    );
  }
}

const Block = props => (
  <Container
    padding={['bottom', 'top']}
    id={props.id}
    background={props.background}>
    <GridBlock align="left" contents={props.children} layout={props.layout} />
  </Container>
);

const FeatureCallout = () => (

      Unleash is a feature toggle system, that gives you a great overview of all feature toggles across
      all your applications and services. It comes with official client implementations for Java, Node.js, Go, Ruby, Python and .Net.

      The main motivation for doing feature toggling is to decouple the process for deploying code to production
      and releasing new features. This helps reducing risk, and allow us to easily manage which features to enable

);

const Survey = () => (

      Support us in making Unleash even better by participating in this

        Unleash Open-Source survey.

      By participating you will also have the chance to win a $25 Amazon gift card.

);

const SASSOffering = () => (

      Unleash also comes in a enterprise edition with additional features and a hosted option.

      Check out
      unleash-hosted.com

);

const UnleashClient = () => (
  <Container padding={['bottom', 'top']} id="unleash-client" background={'light'}>

Client implementations

      Unleash has official SDK's for Java, Node.js, Go, Ruby, Python and .Net. And we will be happy to add implementations in other languages written by you! These libraries make it very easy to use Unleash in your application.

Official client SDKs:

<MarkdownBlock>[unleash/unleash-client-java](https://github.com/unleash/unleash-client-java)</MarkdownBlock>

<MarkdownBlock>[unleash/unleash-client-node](https://github.com/unleash/unleash-client-node)</MarkdownBlock>

<MarkdownBlock>[unleash/unleash-client-go](https://github.com/unleash/unleash-client-go)</MarkdownBlock>

<MarkdownBlock>[unleash/unleash-client-ruby](https://github.com/unleash/unleash-client-ruby)</MarkdownBlock>

<MarkdownBlock>[unleash/unleash-client-python](https://github.com/Unleash/unleash-client-python)</MarkdownBlock>

<MarkdownBlock>[unleash/unleash-client-core](https://github.com/Unleash/unleash-client-core) (.Net Core)</MarkdownBlock>

Clients written by awesome enthusiasts:

<MarkdownBlock>[cognitedata/unleash-client-rust](https://github.com/cognitedata/unleash-client-rust) (Rust)</MarkdownBlock>

<MarkdownBlock>[uekoetter.dev/unleash-client-dart](https://pub.dev/packages/unleash) (Dart)</MarkdownBlock>

<MarkdownBlock>[silvercar/unleash-client-kotlin](https://github.com/silvercar/unleash-client-kotlin) (Kotlin)</MarkdownBlock>

<MarkdownBlock>[minds/unleash-client-php](https://gitlab.com/minds/unleash-client-php) (PHP)</MarkdownBlock>

<MarkdownBlock>[afontaine/unleash_ex](https://gitlab.com/afontaine/unleash_ex) (Elixir)</MarkdownBlock>

<MarkdownBlock>[mikefrancis/laravel-unleash](https://github.com/mikefrancis/laravel-unleash) (Laravel - PHP)</MarkdownBlock>

<MarkdownBlock>[AppsFlyer/clojure-unleash](https://github.com/AppsFlyer/unleash-client-clojure) (Clojure)</MarkdownBlock>

<MarkdownBlock>[pmb0/nestjs-unleash](https://github.com/pmb0/nestjs-unleash) (NestJS - Node.js)</MarkdownBlock>

  </Container>
);

const TryOut = () => (
  <Block id="try">
    {[
      {
        content: 'We have deployed a demo version of [Unleash on Heroku](https://unleash.herokuapp.com). '+
            'Here you can play with the Unleash UI, define some feature toggles and get a feel of how to use Unleash.

'+
            'It is even possible to use one of the Unleash client SDKs and test it out Unleash your application. '+
            'To do this, you should connect one of the clients using the hosted API URL: https://unleash.herokuapp.com/api/.',
        image: imgUrl('dashboard_new.png'),
        imageAlign: 'left',
        align: 'left',
        title: 'Try Unleash',
      },
    ]}
  </Block>
);

const ActivationStrategies = () => (
  <Block background="dark">
    {[
      {
        content: 'It\'s great to have a system for turning stuff on and off. Sometimes, however, we want more granular control, and we want to decide who the toggle should be enabled for. This is where activation strategies come into the picture. Activation strategies take arbitrary config and allow us to enable a toggle in various ways.',
        image: imgUrl('logo-inverted.png'),
        imageAlign: 'right',
        title: 'Activation strategies',
      },
    ]}
  </Block>
);

const Showcase = props => {
  if ((siteConfig.users || []).length === 0) {
    return null;
  }

  const showcase = siteConfig.users.filter(user => user.pinned).map(user => (

  ));

  return (

Who is Using Unleash?

Unleash is used by

{showcase}

          More {siteConfig.title} Users

  );
};

class Index extends React.Component {
  render() {
    const language = this.props.language || '';

    return (

        <HomeSplash language={language} config={this.props.config} />

          <UnleashClient />
          <TryOut />
          <ActivationStrategies />
          <Showcase language={language} />

    );
  }
}

module.exports = Index;
<commit_msg>chore: fix getting started link on docs index<commit_after>/**
 * Copyright (c) 2017-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

const React = require('react');

const CompLibrary = require('../../core/CompLibrary.js');

const MarkdownBlock = CompLibrary.MarkdownBlock; /* Used to read markdown */
const Container = CompLibrary.Container;
const GridBlock = CompLibrary.GridBlock;

const siteConfig = require(`${process.cwd()}/siteConfig.js`);

function imgUrl(img) {
  return `${siteConfig.baseUrl}img/${img}`;
}

function docUrl(doc, language) {
  return `${siteConfig.baseUrl}docs/${language ? `${language}/` : ''}${doc}`;
}

function pageUrl(page, language) {
  return siteConfig.baseUrl + (language ? `${language}/` : '') + page;
}

const Button = ({className = '', href, target, children}) => (

      {children}

);

Button.defaultProps = {
  target: '_self',
};

const SplashContainer = props => (

{props.children}

);

const Logo = props => (

);

const LogoSvg = ({style}) => (
  <svg style={style} viewBox="0 0 200 60" xmlns="http://www.w3.org/2000/svg">
    <g transform="translate(280.822 -299.303)">
      <text
        style={{
          lineHeight: "0%",
          InkscapeFontSpecification: "'Ubuntu, Medium'",
          textAlign: "start",
        }}
        fontFamily="Ubuntu"
        x="-227.697"
        y="343.108"
      >
        <tspan
          style={{
            lineHeight: "100%",
            InkscapeFontSpecification: "'Ubuntu, Medium'",
            textAlign: "start",
          }}
          fontSize="37.5"
          x="-227.697"
          y="343.108"
        >
          Unleash
        </tspan>
      </text>
      <rect
        height="22.483"
        width="40.186"
        fill="#0b1700"
        rx="9.74"
        x="-272.312"
        y="318.151"
      />
      <rect
        height="12.604"
        width="14.489"
        fill="#fff"
        rx="4.135"
        x="-251.511"
        y="323.352"
      />
    </g>
  </svg>
);

const ProjectTitle = () => (

    {siteConfig.tagline}

);

const PromoSection = props => (

{props.children}

);

class HomeSplash extends React.Component {
  render() {
    const language = this.props.language || '';
    return (
      <SplashContainer>

          <Survey />
          <ProjectTitle />

              Star

          <FeatureCallout />
          <PromoSection>
            <Button className="primary" href={docUrl('deploy/getting_started', language)}>Getting Started</Button>
            <Button href="#try">Try It Out</Button>
            <Button href={siteConfig.repoUrl}>GitHub</Button>
          </PromoSection>

          <SASSOffering />

      </SplashContainer>
    );
  }
}

const Block = props => (
  <Container
    padding={['bottom', 'top']}
    id={props.id}
    background={props.background}>
    <GridBlock align="left" contents={props.children} layout={props.layout} />
  </Container>
);

const FeatureCallout = () => (

      Unleash is a feature toggle system, that gives you a great overview of all feature toggles across
      all your applications and services. It comes with official client implementations for Java, Node.js, Go, Ruby, Python and .Net.

      The main motivation for doing feature toggling is to decouple the process for deploying code to production
      and releasing new features. This helps reducing risk, and allow us to easily manage which features to enable

);

const Survey = () => (

      Support us in making Unleash even better by participating in this

        Unleash Open-Source survey.

      By participating you will also have the chance to win a $25 Amazon gift card.

);

const SASSOffering = () => (

      Unleash also comes in a enterprise edition with additional features and a hosted option.

      Check out
      unleash-hosted.com

);

const UnleashClient = () => (
  <Container padding={['bottom', 'top']} id="unleash-client" background={'light'}>

Client implementations

      Unleash has official SDK's for Java, Node.js, Go, Ruby, Python and .Net. And we will be happy to add implementations in other languages written by you! These libraries make it very easy to use Unleash in your application.

Official client SDKs:

<MarkdownBlock>[unleash/unleash-client-java](https://github.com/unleash/unleash-client-java)</MarkdownBlock>

<MarkdownBlock>[unleash/unleash-client-node](https://github.com/unleash/unleash-client-node)</MarkdownBlock>

<MarkdownBlock>[unleash/unleash-client-go](https://github.com/unleash/unleash-client-go)</MarkdownBlock>

<MarkdownBlock>[unleash/unleash-client-ruby](https://github.com/unleash/unleash-client-ruby)</MarkdownBlock>

<MarkdownBlock>[unleash/unleash-client-python](https://github.com/Unleash/unleash-client-python)</MarkdownBlock>

<MarkdownBlock>[unleash/unleash-client-core](https://github.com/Unleash/unleash-client-core) (.Net Core)</MarkdownBlock>

Clients written by awesome enthusiasts:

<MarkdownBlock>[cognitedata/unleash-client-rust](https://github.com/cognitedata/unleash-client-rust) (Rust)</MarkdownBlock>

<MarkdownBlock>[uekoetter.dev/unleash-client-dart](https://pub.dev/packages/unleash) (Dart)</MarkdownBlock>

<MarkdownBlock>[silvercar/unleash-client-kotlin](https://github.com/silvercar/unleash-client-kotlin) (Kotlin)</MarkdownBlock>

<MarkdownBlock>[minds/unleash-client-php](https://gitlab.com/minds/unleash-client-php) (PHP)</MarkdownBlock>

<MarkdownBlock>[afontaine/unleash_ex](https://gitlab.com/afontaine/unleash_ex) (Elixir)</MarkdownBlock>

<MarkdownBlock>[mikefrancis/laravel-unleash](https://github.com/mikefrancis/laravel-unleash) (Laravel - PHP)</MarkdownBlock>

<MarkdownBlock>[AppsFlyer/clojure-unleash](https://github.com/AppsFlyer/unleash-client-clojure) (Clojure)</MarkdownBlock>

<MarkdownBlock>[pmb0/nestjs-unleash](https://github.com/pmb0/nestjs-unleash) (NestJS - Node.js)</MarkdownBlock>

  </Container>
);

const TryOut = () => (
  <Block id="try">
    {[
      {
        content: 'We have deployed a demo version of [Unleash on Heroku](https://unleash.herokuapp.com). '+
            'Here you can play with the Unleash UI, define some feature toggles and get a feel of how to use Unleash.

'+
            'It is even possible to use one of the Unleash client SDKs and test it out Unleash your application. '+
            'To do this, you should connect one of the clients using the hosted API URL: https://unleash.herokuapp.com/api/.',
        image: imgUrl('dashboard_new.png'),
        imageAlign: 'left',
        align: 'left',
        title: 'Try Unleash',
      },
    ]}
  </Block>
);

const ActivationStrategies = () => (
  <Block background="dark">
    {[
      {
        content: 'It\'s great to have a system for turning stuff on and off. Sometimes, however, we want more granular control, and we want to decide who the toggle should be enabled for. This is where activation strategies come into the picture. Activation strategies take arbitrary config and allow us to enable a toggle in various ways.',
        image: imgUrl('logo-inverted.png'),
        imageAlign: 'right',
        title: 'Activation strategies',
      },
    ]}
  </Block>
);

const Showcase = props => {
  if ((siteConfig.users || []).length === 0) {
    return null;
  }

  const showcase = siteConfig.users.filter(user => user.pinned).map(user => (

  ));

  return (

Who is Using Unleash?

Unleash is used by

{showcase}

          More {siteConfig.title} Users

  );
};

class Index extends React.Component {
  render() {
    const language = this.props.language || '';

    return (

        <HomeSplash language={language} config={this.props.config} />

          <UnleashClient />
          <TryOut />
          <ActivationStrategies />
          <Showcase language={language} />

    );
  }
}

module.exports = Index;
<|endoftext|>


<commit_before>const React = require("react");

const CompLibrary = require("../../core/CompLibrary.js");

const variables = require(process.cwd() + "/variables.js");

const MarkdownBlock = CompLibrary.MarkdownBlock;
const Container = CompLibrary.Container;
const GridBlock = CompLibrary.GridBlock;

class HomeSplash extends React.Component {
  render() {
    const { siteConfig, language = "" } = this.props;
    const { baseUrl, docsUrl } = siteConfig;
    const docsPart = `${docsUrl ? `${docsUrl}/` : ""}`;
    const langPart = `${language ? `${language}/` : ""}`;
    const docUrl = doc => `${baseUrl}${docsPart}${langPart}${doc}`;

    const SplashContainer = props => (

{props.children}

    );

    const ProjectTitle = () => (

          {siteConfig.title}

        {siteConfig.tagline}

    );

    const PromoSection = props => (

{props.children}

    );

    const Button = props => (

          {props.children}

    );

    return (
      <SplashContainer>

          <ProjectTitle siteConfig={siteConfig} />
          <PromoSection>
            <Button href={siteConfig.apiUrl}>API Docs</Button>
            <Button href={docUrl("overview", language)}>Documentation</Button>
            <Button href={siteConfig.repoUrl}>View on GitHub</Button>
          </PromoSection>

      </SplashContainer>
    );
  }
}

class Index extends React.Component {
  render() {
    const { config: siteConfig, language = "" } = this.props;
    const { baseUrl } = siteConfig;

    const {
      organization,
      coreModuleName,
      latestVersion,
      scalaPublishVersions
    } = variables;

    const latestVersionBadge = latestVersion
      .replace("-", "--")
      .replace("_", "__");

    const Block = props => (
      <Container
        padding={["bottom", "top"]}
        id={props.id}
        background={props.background}
      >
        <GridBlock
          align="center"
          contents={props.children}
          layout={props.layout}
        />
      </Container>
    );

    const index = `[![Typelevel](https://img.shields.io/badge/typelevel-library-fd3d50.svg)](https://typelevel.org/projects/#ciris) [![Travis](https://img.shields.io/travis/vlovgr/ciris/master.svg)](https://travis-ci.org/vlovgr/ciris) [![Codecov](https://img.shields.io/codecov/c/github/vlovgr/ciris.svg)](https://codecov.io/gh/vlovgr/ciris) [![Gitter](https://img.shields.io/gitter/room/vlovgr/ciris.svg?colorB=36bc97)](https://gitter.im/vlovgr/ciris) [![Version](https://img.shields.io/badge/version-v${latestVersionBadge}-orange.svg)](https://index.scala-lang.org/vlovgr/ciris)

Functional, lightweight, and composable configuration loading for Scala.

Project is under active development. Feedback and contributions welcome.

### Getting Started
To get started with [sbt](https://scala-sbt.org), simply add the following line to your \`build.sbt\` file.

\`\`\`scala
libraryDependencies += "${organization}" %% "${coreModuleName}" % "${latestVersion}"
\`\`\`

Published for Scala ${scalaPublishVersions}. For changes, refer to the [release notes](https://github.com/vlovgr/ciris/releases).
`.trim();

    return (

        <HomeSplash siteConfig={siteConfig} language={language} />

            <MarkdownBlock>{index}</MarkdownBlock>

    );
  }
}

module.exports = Index;
<commit_msg>Change ci status badge to github actions<commit_after>const React = require("react");

const CompLibrary = require("../../core/CompLibrary.js");

const variables = require(process.cwd() + "/variables.js");

const MarkdownBlock = CompLibrary.MarkdownBlock;
const Container = CompLibrary.Container;
const GridBlock = CompLibrary.GridBlock;

class HomeSplash extends React.Component {
  render() {
    const { siteConfig, language = "" } = this.props;
    const { baseUrl, docsUrl } = siteConfig;
    const docsPart = `${docsUrl ? `${docsUrl}/` : ""}`;
    const langPart = `${language ? `${language}/` : ""}`;
    const docUrl = doc => `${baseUrl}${docsPart}${langPart}${doc}`;

    const SplashContainer = props => (

{props.children}

    );

    const ProjectTitle = () => (

          {siteConfig.title}

        {siteConfig.tagline}

    );

    const PromoSection = props => (

{props.children}

    );

    const Button = props => (

          {props.children}

    );

    return (
      <SplashContainer>

          <ProjectTitle siteConfig={siteConfig} />
          <PromoSection>
            <Button href={siteConfig.apiUrl}>API Docs</Button>
            <Button href={docUrl("overview", language)}>Documentation</Button>
            <Button href={siteConfig.repoUrl}>View on GitHub</Button>
          </PromoSection>

      </SplashContainer>
    );
  }
}

class Index extends React.Component {
  render() {
    const { config: siteConfig, language = "" } = this.props;
    const { baseUrl } = siteConfig;

    const {
      organization,
      coreModuleName,
      latestVersion,
      scalaPublishVersions
    } = variables;

    const latestVersionBadge = latestVersion
      .replace("-", "--")
      .replace("_", "__");

    const Block = props => (
      <Container
        padding={["bottom", "top"]}
        id={props.id}
        background={props.background}
      >
        <GridBlock
          align="center"
          contents={props.children}
          layout={props.layout}
        />
      </Container>
    );

    const index = `[![Typelevel](https://img.shields.io/badge/typelevel-library-fd3d50.svg)](https://typelevel.org/projects/#ciris) [![GitHub Actions](https://img.shields.io/github/workflow/status/vlovgr/ciris/ci)](https://github.com/vlovgr/ciris/actions) [![Codecov](https://img.shields.io/codecov/c/github/vlovgr/ciris.svg)](https://codecov.io/gh/vlovgr/ciris) [![Gitter](https://img.shields.io/gitter/room/vlovgr/ciris.svg?colorB=36bc97)](https://gitter.im/vlovgr/ciris) [![Version](https://img.shields.io/badge/version-v${latestVersionBadge}-orange.svg)](https://index.scala-lang.org/vlovgr/ciris)

Functional, lightweight, and composable configuration loading for Scala.

Project is under active development. Feedback and contributions welcome.

### Getting Started
To get started with [sbt](https://scala-sbt.org), simply add the following line to your \`build.sbt\` file.

\`\`\`scala
libraryDependencies += "${organization}" %% "${coreModuleName}" % "${latestVersion}"
\`\`\`

Published for Scala ${scalaPublishVersions}. For changes, refer to the [release notes](https://github.com/vlovgr/ciris/releases).
`.trim();

    return (

        <HomeSplash siteConfig={siteConfig} language={language} />

            <MarkdownBlock>{index}</MarkdownBlock>

    );
  }
}

module.exports = Index;
<|endoftext|>


<commit_before>"use strict";

const React = require("react");
const PropTypes = require("prop-types");
const AnimatedLogo = require("@sandhose/prettier-animated-logo");
const { MarkdownBlock, Container } = require("../../core/CompLibrary.js");

const siteConfig = require(process.cwd() + "/siteConfig.js");

const ButtonGroup = (props) => (

{props.children}

);

ButtonGroup.propTypes = {
  children: PropTypes.node,
};

class Button extends React.Component {
  render() {
    return (

          {this.props.children}

    );
  }
}

Button.defaultProps = {
  target: "_self",
};

Button.propTypes = {
  href: PropTypes.string,
  target: PropTypes.string,
  children: PropTypes.any,
};

function Tidelift() {
  return (

      PRETTIER FOR ENTERPRISE

  );
}

const HomeSplash = (props) => (

    <Tidelift />

          <AnimatedLogo version="wide" />

                <Button href="/playground/">Try It Online</Button>
                <Button href={"/docs/" + props.language + "/install.html"}>
                  Install Prettier
                </Button>

);

HomeSplash.propTypes = {
  language: PropTypes.string,
};

const TldrSection = ({ language }) => (

    <Container>

What is Prettier?

An opinionated code formatter

Supports many languages

Integrates with most editors

Has few options

Why?

You press save and code is formatted

No need to discuss style in code review

Saves you time and energy

              And more

    </Container>

);

TldrSection.propTypes = {
  language: PropTypes.string,
};

const Language = ({ name, nameLink, showName, image, variants }) => (

      {showName && (

          {nameLink ? {name} : name}

      )}
      {variants.map((variant) => (

          <MarkdownBlock>{variant}</MarkdownBlock>

      ))}

);

Language.propTypes = {
  name: PropTypes.string,
  nameLink: PropTypes.string,
  showName: PropTypes.bool,
  image: PropTypes.string,
  variants: PropTypes.array,
};

const LanguagesSection = () => {
  const languageChunks = siteConfig.supportedLanguages.reduce(
    (acc, language) => {
      const last = acc[acc.length - 1];
      if (
        last &&
        last.length < 2 &&
        last.reduce((sum, lang) => sum + lang.variants.length, 0) +
          language.variants.length <
          9
      ) {
        last.push(language);
      } else {
        acc.push([language]);
      }
      return acc;
    },
    []
  );

  return (

      <Container>

Works with the Tools You Use

          {languageChunks.map((languageChunk, index) => (

              {languageChunk.map((language) => (
                <Language key={language.name} {...language} />
              ))}

          ))}

      </Container>

  );
};

const Editor = ({ content = "", image, name }) => (

{name}

      <MarkdownBlock>{content.replace(/\n/g, "  \n")}</MarkdownBlock>

);

Editor.propTypes = {
  content: PropTypes.string,
  image: PropTypes.string.isRequired,
  name: PropTypes.string.isRequired,
};

const EditorSupportSection = () => (

    <Container>

Editor Support

        {siteConfig.editors.map((editor) => (
          <Editor key={editor.name} {...editor} />
        ))}

    </Container>

      Got more?
      <a
        href={`${siteConfig.githubUrl}/edit/main/website/data/editors.yml`}
        className="button"
      >
        Send a PR

);

const UsersSection = ({ language }) => {
  const showcase = siteConfig.users
    .filter((user) => user.pinned)
    .map((user, i) => (

    ));

  return (

      <Container>

Used By People You Rely On

          {showcase}

            See Others

Established in the Ecosystem

                Regularly used by more than 70% of respondents
                to State of JS 2020

              <Button href="https://2020.stateofjs.com/en-US/other-tools/utilities">
                Go to Survey Results
              </Button>

                More than{" "}
                2.3 million{" "}
                dependent repositories on GitHub

              <Button href="https://github.com/prettier/prettier/network/dependents">
                Check Them Out
              </Button>

                More than 6000{" "}
                dependent packages on npm

              <Button href="https://www.npmjs.com/browse/depended/prettier">
                See them all
              </Button>

      </Container>

  );
};

UsersSection.propTypes = {
  language: PropTypes.string,
};

class Index extends React.Component {
  render() {
    const language = this.props.language || "en";

    return (