<commit_before>// _head controller

import { stat } from 'fs/promises'

export const handler = async (params) => {
  let cssKey = params.session.themePath.css + '/min/site.css',
      cssUrl = app.config.comitium.staticAssetUrl + 'themes/' + params.session.themePath.css + '/min/site.css?v=',
      jsKey = params.session.themePath.js + '/min/site.js',
      jsUrl = app.config.comitium.staticAssetUrl + 'themes/' + params.session.themePath.js + '/min/site.js?v=',
      staticFileStats = app.config.citizen.cache.static.enable ? app.cache.get({ scope: 'staticFileStats' }) : false,
      metaData = params.route.action === 'handler' && app.controllers[params.route.controller] && app.controllers[params.route.controller].head ? await app.controllers[params.route.controller].head(params) : {}

  // If the static files are cached, generate the URLs
  if ( staticFileStats && staticFileStats[cssKey] && staticFileStats[jsKey] ) {
    return {
      public: {
        metaData: metaData,
        cssUrl: cssUrl + staticFileStats[cssKey].mtime.toString().replace(/[ :\-()]/g, ''),
        jsUrl: jsUrl + staticFileStats[jsKey].mtime.toString().replace(/[ :\-()]/g, '')
      }
    }
  // Read the files if they're not in the cache
  } else {
    let [
      css,
      js
    ] = await Promise.all([
      stat(app.config.citizen.directories.web + '/themes/' + params.session.themePath.css + '/min/site.css'),
      stat(app.config.citizen.directories.web + '/themes/' + params.session.themePath.js + '/min/site.js')<commit_msg>Fixed broken theme path during sign-out<commit_after>// _head controller

import { stat } from 'fs/promises'

export const handler = async (params) => {
  let themePath = params.session.themePath || app.config.comitium.themes[Object.keys(app.config.comitium.themes)[0]].path,
      cssKey = themePath.css + '/min/site.css',
      cssUrl = app.config.comitium.staticAssetUrl + 'themes/' + themePath.css + '/min/site.css?v=',
      jsKey = themePath.js + '/min/site.js',
      jsUrl = app.config.comitium.staticAssetUrl + 'themes/' + themePath.js + '/min/site.js?v=',
      staticFileStats = app.config.citizen.cache.static.enable ? app.cache.get({ scope: 'staticFileStats' }) : false,
      metaData = params.route.action === 'handler' && app.controllers[params.route.controller] && app.controllers[params.route.controller].head ? await app.controllers[params.route.controller].head(params) : {}

  // If the static files are cached, generate the URLs
  if ( staticFileStats && staticFileStats[cssKey] && staticFileStats[jsKey] ) {
    return {
      public: {
        metaData: metaData,
        cssUrl: cssUrl + staticFileStats[cssKey].mtime.toString().replace(/[ :\-()]/g, ''),
        jsUrl: jsUrl + staticFileStats[jsKey].mtime.toString().replace(/[ :\-()]/g, '')
      }
    }
  // Read the files if they're not in the cache
  } else {
    let [
      css,
      js
    ] = await Promise.all([
      stat(app.config.citizen.directories.web + '/themes/' + themePath.css + '/min/site.css'),
      stat(app.config.citizen.directories.web + '/themes/' + themePath.js + '/min/site.js')
{'fraction_non_alphanumeric': 0.16747026679524268, 'fraction_numerical': 0.0003214400514304082, 'mean_word_length': 3.2282608695652173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1862208', 'n_tokens_mistral': 1013, 'n_tokens_neox': 990, 'n_words': 187}