<commit_before>const App = require('ghost-app');

const BASE_URL = process.env.BASE_TOMMY_URL || 'http://tommy-web.ertrzyiks.me/'

function renderTommyIframe(slug) {
  return `
<div class="post-iframe_placeholder--tommy">
  <div class="post-iframe_wrapper--tommy">
    <button class="post-iframe_button--tommy is-hidden" style="display: none" data-role="load-exercise">Load the exercise</button>
    <iframe class="post-iframe--tommy" data-src="${BASE_URL}${slug}" style="width: 100%; height: 600px"></iframe>
  </div>
</div>
`
}

function replaceWithTommyIframe(html) {
  return html.replace(/<!--TOMMY (.+?) YMMOT-->/g, function (match, slug) {
    return renderTommyIframe(slug)
  })
}

const cssUrl = '/assets/my-ghost-tommy/css/tommy.css?v=1'
const jsUrl = '/assets/my-ghost-tommy/js/tommy.js?v=1'

var MyApp = App.extend({
  filters: {
    prePostsRender: 'handlePrePostRender',
    ghost_head: 'handleGhostHead',
    ghost_foot: 'handleGhostFoot',
  },
  handlePrePostRender: function (post) {
    if (post.html) {
      post.html = replaceWithTommyIframe(post.html)
    }
    return post;
  },

  handleGhostHead: function (head) {
    head.push(`<link rel="preload" href="${cssUrl}" as="style">`)
    return head;
  },

  handleGhostFoot: function (foot) {
    foot.push(`<script>
      var link = document.createElement('link');
      link.rel = 'stylesheet';
      link.href = '${cssUrl}';
      link.type = 'text/css';
      var ref = document.getElementsByTagName('link')[0];
      ref.parentNode.insertBefore(link, ref);
    </script>`)
    foot.push(`<script async defer src="${jsUrl}"></script>\n`)

    return foot
  }
});

module.exports = MyApp
<commit_msg>Hide ugly iframe borders<commit_after>const App = require('ghost-app');

const BASE_URL = process.env.BASE_TOMMY_URL || 'http://tommy-web.ertrzyiks.me/'

function renderTommyIframe(slug) {
  return `
<div class="post-iframe_placeholder--tommy">
  <div class="post-iframe_wrapper--tommy">
    <button class="post-iframe_button--tommy is-hidden" style="display: none;" data-role="load-exercise">Load the exercise</button>
    <iframe class="post-iframe--tommy" data-src="${BASE_URL}${slug}" style="width: 100%; height: 600px; border: none;"></iframe>
  </div>
</div>
`
}

function replaceWithTommyIframe(html) {
  return html.replace(/<!--TOMMY (.+?) YMMOT-->/g, function (match, slug) {
    return renderTommyIframe(slug)
  })
}

const cssUrl = '/assets/my-ghost-tommy/css/tommy.css?v=1'
const jsUrl = '/assets/my-ghost-tommy/js/tommy.js?v=1'

var MyApp = App.extend({
  filters: {
    prePostsRender: 'handlePrePostRender',
    ghost_head: 'handleGhostHead',
    ghost_foot: 'handleGhostFoot',
  },
  handlePrePostRender: function (post) {
    if (post.html) {
      post.html = replaceWithTommyIframe(post.html)
    }
    return post;
  },

  handleGhostHead: function (head) {
    head.push(`<link rel="preload" href="${cssUrl}" as="style">`)
    return head;
  },

  handleGhostFoot: function (foot) {
    foot.push(`<script>
      var link = document.createElement('link');
      link.rel = 'stylesheet';
      link.href = '${cssUrl}';
      link.type = 'text/css';
      var ref = document.getElementsByTagName('link')[0];
      ref.parentNode.insertBefore(link, ref);
    </script>`)
    foot.push(`<script async defer src="${jsUrl}"></script>\n`)

    return foot
  }
});

module.exports = MyApp

{'fraction_non_alphanumeric': 0.17579165433560226, 'fraction_numerical': 0.005327019828351583, 'mean_word_length': 3.898550724637681, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '4806164', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1189, 'n_words': 209}