<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

const
config = require('../../lib/configuration');


function getBookmarkletHref(){
  //TODO: Cleanup
  var baseCode = "javascript:(function()%7Bvar%20script=document.createElement('script');script.src='" + 
                 config.get('public_url') + 
                 "/bookmarklet.js';script.className='TowTruck';document.head.appendChild(script);%7D)();"

  return baseCode;
}

/*
 * GET home page.
 */
exports.index = function(req, res){
  res.render('site', {bodyClass: 'home', layout: false, bookmarkletHref: getBookmarkletHref()});
};

/*
 * GET /bookmarklet.js
 */
exports.bookmarklet = function(req, res){
  res.header('Content-Type', 'application/javascript');
  res.render('site/bookmarklet.js.ejs', {layout: false, baseUrl: config.get('public_url')});
};<commit_msg>Allowing CORS requests in the site controller.<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

const
config = require('../../lib/configuration');


function getBookmarkletHref(){
  //TODO: Cleanup
  var baseCode = "javascript:(function()%7Bvar%20script=document.createElement('script');script.src='" + 
                 config.get('public_url') + 
                 "/bookmarklet.js';script.className='TowTruck';document.head.appendChild(script);%7D)();"

  return baseCode;
}

/*
 * GET home page.
 */
exports.index = function(req, res){
  res.render('site', {bodyClass: 'home', layout: false, bookmarkletHref: getBookmarkletHref()});
};

/*
 * GET /bookmarklet.js
 */
exports.bookmarklet = function(req, resp){
  resp.header('Access-Control-Allow-Origin', '*');
  resp.header('Content-Type', 'application/javascript');
  resp.render('site/bookmarklet.js.ejs', {layout: false, baseUrl: config.get('public_url')});
};

exports.allowCorsRequests = function(req, resp){
  resp.header('Access-Control-Allow-Origin', '*');
  resp.send('');
};
{'fraction_non_alphanumeric': 0.1716485507246377, 'fraction_numerical': 0.007246376811594203, 'mean_word_length': 4.1016166281755195, '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': '888368', 'n_tokens_mistral': 717, 'n_tokens_neox': 695, 'n_words': 160}