<commit_before>import fs from 'fs';
import path from 'path';
import moment from '@/config/moment';
import firebase from '@/config/firebase-admin';
import * as hbsTemplates from '@/config/handlebars';
import writefile from './writefile';
import Post from '@/models/Post';
import * as helpers from './helpers';
import { slugger } from '@/config/constants';

const cssInlineThreshold = 10; // KB
const logoURL = helpers.logoURL;
const database = firebase.database();
const publishedRef = database.ref('/published').orderByChild('created');

function inlineCSS(file) {
  if (!file.endsWith('.css')) return '';

  const filePath = path.resolve(process.cwd() + '/public' + file);
  const fileStats = fs.statSync(filePath);
  let html = '';

  if (fileStats.size / 1000.0 < cssInlineThreshold) {
    // Inline the file
    const fileContent = fs.readFileSync(filePath, 'utf8');
    html = `<style>${fileContent}</style>`;
  } else {
    html = `<link rel="stylesheet" href="${file}">`;
  }

  return html;
}

function webpackManifest() {
  const manifest = JSON.parse(fs.readFileSync('public/config/webpack.manifest.json', 'utf8'));
  Object.keys(manifest).map((entry) => {
    manifest[entry] = entry.endsWith('.css') ? inlineCSS(manifest[entry]) : manifest[entry];
  });

  return manifest;
}

export function buildGallery() {
  return new Promise((resolve) => {
    publishedRef.once('value', (snapshot) => {
      const val = snapshot.val();
      const postsArray = Object.keys(val).map(key => val[key]).reverse();
      const postsPerMonth = {};
      const filePath = 'public/gallery.html';

      postsArray.map((post) => {
        const createdDate = moment(post.created, 'DD.MM.YYYY');<commit_msg>Change galerie output name to german<commit_after>import fs from 'fs';
import path from 'path';
import moment from '@/config/moment';
import firebase from '@/config/firebase-admin';
import * as hbsTemplates from '@/config/handlebars';
import writefile from './writefile';
import Post from '@/models/Post';
import * as helpers from './helpers';
import { slugger } from '@/config/constants';

const cssInlineThreshold = 10; // KB
const logoURL = helpers.logoURL;
const database = firebase.database();
const publishedRef = database.ref('/published').orderByChild('created');

function inlineCSS(file) {
  if (!file.endsWith('.css')) return '';

  const filePath = path.resolve(process.cwd() + '/public' + file);
  const fileStats = fs.statSync(filePath);
  let html = '';

  if (fileStats.size / 1000.0 < cssInlineThreshold) {
    // Inline the file
    const fileContent = fs.readFileSync(filePath, 'utf8');
    html = `<style>${fileContent}</style>`;
  } else {
    html = `<link rel="stylesheet" href="${file}">`;
  }

  return html;
}

function webpackManifest() {
  const manifest = JSON.parse(fs.readFileSync('public/config/webpack.manifest.json', 'utf8'));
  Object.keys(manifest).map((entry) => {
    manifest[entry] = entry.endsWith('.css') ? inlineCSS(manifest[entry]) : manifest[entry];
  });

  return manifest;
}

export function buildGallery() {
  return new Promise((resolve) => {
    publishedRef.once('value', (snapshot) => {
      const val = snapshot.val();
      const postsArray = Object.keys(val).map(key => val[key]).reverse();
      const postsPerMonth = {};
      const filePath = 'public/galerie.html';

      postsArray.map((post) => {
        const createdDate = moment(post.created, 'DD.MM.YYYY');
{'fraction_non_alphanumeric': 0.16593631317557697, 'fraction_numerical': 0.0052585451358457495, 'mean_word_length': 4.1878787878787875, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, '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': '766966', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1042, 'n_words': 252}