<commit_before>from staticjinja import make_site
from glob2 import glob
import json
import os
import codecs
import cgi

entries = {}

def main():
    global entries
    
    s = make_site(
        contexts=[
            ('.*.json', load_publication),
            ('index.html', load_entries)
        ],
        rules=[
            ('.*.json', render_publication),
        ],
        outpath='output',
        staticpaths=('static/',)
    )
    s.render(use_reloader=True)

def load_entries(template):
    # Load JSON files
    entries = []
    for fname in glob("publications/**/*.json"):
        entry = json.loads(open(fname, 'r').read())
        entries.append(entry)
        
    from collections import OrderedDict
    groups = OrderedDict()
    for year in sorted(set([e['year'] for e in entries]))[::-1]:
        groups[year] = []
    
    for e in entries:
        groups[e['year']].append(e)

    return {'entry_groups': groups}
    
def load_publication(template):
    with codecs.open(template.filename, encoding='utf-8') as f:
        return json.loads(f.read())

def render_publication(env, template, **entry):
    """Render a template as a publication."""<commit_msg>Removed reloader from gensite.py<commit_after>from staticjinja import make_site
from glob2 import glob
import json
import os
import codecs
import cgi

entries = {}

def main():
    global entries
    
    s = make_site(
        contexts=[
            ('.*.json', load_publication),
            ('index.html', load_entries)
        ],
        rules=[
            ('.*.json', render_publication),
        ],
        outpath='output',
        staticpaths=('static/',)
    )
    s.render()

def load_entries(template):
    # Load JSON files
    entries = []
    for fname in glob("publications/**/*.json"):
        entry = json.loads(open(fname, 'r').read())
        entries.append(entry)
        
    from collections import OrderedDict
    groups = OrderedDict()
    for year in sorted(set([e['year'] for e in entries]))[::-1]:
        groups[year] = []
    
    for e in entries:
        groups[e['year']].append(e)

    return {'entry_groups': groups}
    
def load_publication(template):
    with codecs.open(template.filename, encoding='utf-8') as f:
        return json.loads(f.read())

def render_publication(env, template, **entry):
    """Render a template as a publication."""
{'fraction_non_alphanumeric': 0.13874788494077833, 'fraction_numerical': 0.0025380710659898475, 'mean_word_length': 2.5351270553064276, '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': '3156871', 'n_tokens_mistral': 713, 'n_tokens_neox': 710, 'n_words': 182}