<commit_before>from browser import document, markdown, html
import highlight

def _keydown(ev, path, zone, page):
    if ev.keyCode in [32,39,40]: # key space, right or down : next page
        show(path, zone, page+1)
        ev.preventDefault()    
    elif ev.keyCode in [37,38]: #key left or up: previous page
        show(path, zone, page-1)
        ev.preventDefault()

def keydown(ev, slideshow, zone):
    if ev.keyCode in [32,39,40]: # key space, right or down : next page
        slideshow.page_num += 1
        if slideshow.page_num >= len(slideshow.pages):
            slideshow.page_num = 0
    elif ev.keyCode in [37,38]: #key left or up: previous page
        slideshow.page_num -= 1
        if slideshow.page_num < 0:
            slideshow.page_num = len(slideshow.pages)-1
    show_page(slideshow, zone, slideshow.page_num)
    ev.preventDefault()  

def move_to(ev, slideshow, zone):
    pc = (ev.x-ev.target.abs_left)/ev.target.width
    nb_pages = len(slideshow.pages)-1
    page = round(nb_pages*pc)
    slideshow.page_num = page
    new_pos = '%spx' %(ev.x-ev.target.abs_left-(document['tl_pos'].width/2))
    # show page at specified position
    show_page(slideshow, zone, page)
    # set new cursor position
    document['tl_pos'].style.left = new_pos

def click_on_tl_pos(ev):
    # don't move if user clicks on current timeline position
    ev.stopPropagation()

class Slideshow:

    def __init__(self, path):
        self.src = src = open(path).read()
        self.title = ''
        self.show_page_num = False
        
        # table of contents : matches matter with page number
        self.contents = []
        
        # directives for the document
        while src.startswith('@'):
            line_end = src.find('\n')
            key,value = src[:line_end].split(' ',1)
            if key=='@title':
                self.title = value
            elif key=='@pagenum':
                self.show_page_num = True
            elif key=="@index":
                self.contents.append([value, 0])
            src = src[line_end+1:]

        self.pages = []
        lines = []
        for line in src.split('\n'):
            if line.startswith('../..'):
                self.pages.append('\n'.join(lines))
                lines = []
            elif line.startswith('@pause'):
                self.pages.append('\n'.join(lines))
            elif line.startswith('@index'):
                self.contents.append([line.split(' ',1)[1], len(self.pages)])
            else:
                lines.append(line)
<commit_msg>Add fake query string to avoid caching<commit_after>from browser import document, markdown, html
import time
import highlight

def _keydown(ev, path, zone, page):
    if ev.keyCode in [32,39,40]: # key space, right or down : next page
        show(path, zone, page+1)
        ev.preventDefault()    
    elif ev.keyCode in [37,38]: #key left or up: previous page
        show(path, zone, page-1)
        ev.preventDefault()

def keydown(ev, slideshow, zone):
    if ev.keyCode in [32,39,40]: # key space, right or down : next page
        slideshow.page_num += 1
        if slideshow.page_num >= len(slideshow.pages):
            slideshow.page_num = 0
    elif ev.keyCode in [37,38]: #key left or up: previous page
        slideshow.page_num -= 1
        if slideshow.page_num < 0:
            slideshow.page_num = len(slideshow.pages)-1
    show_page(slideshow, zone, slideshow.page_num)
    ev.preventDefault()  

def move_to(ev, slideshow, zone):
    pc = (ev.x-ev.target.abs_left)/ev.target.width
    nb_pages = len(slideshow.pages)-1
    page = round(nb_pages*pc)
    slideshow.page_num = page
    new_pos = '%spx' %(ev.x-ev.target.abs_left-(document['tl_pos'].width/2))
    # show page at specified position
    show_page(slideshow, zone, page)
    # set new cursor position
    document['tl_pos'].style.left = new_pos

def click_on_tl_pos(ev):
    # don't move if user clicks on current timeline position
    ev.stopPropagation()

class Slideshow:

    def __init__(self, path):
        self.src = src = open(path+'?foo=%s' %time.time()).read()
        self.title = ''
        self.show_page_num = False
        
        # table of contents : matches matter with page number
        self.contents = []
        
        # directives for the document
        while src.startswith('@'):
            line_end = src.find('\n')
            key,value = src[:line_end].split(' ',1)
            if key=='@title':
                self.title = value
            elif key=='@pagenum':
                self.show_page_num = True
            elif key=="@index":
                self.contents.append([value, 0])
            src = src[line_end+1:]

        self.pages = []
        lines = []
        for line in src.split('\n'):
            if line.startswith('../..'):
                self.pages.append('\n'.join(lines))
                lines = []
            elif line.startswith('@pause'):
                self.pages.append('\n'.join(lines))
            elif line.startswith('@index'):
                self.contents.append([line.split(' ',1)[1], len(self.pages)])
            else:
                lines.append(line)

{'fraction_non_alphanumeric': 0.13056954668733048, 'fraction_numerical': 0.0131731886865556, 'mean_word_length': 2.1046301864101022, 'pattern_counts': {'":': 2, '<': 5, '<?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': '449387', 'n_tokens_mistral': 1653, 'n_tokens_neox': 1611, 'n_words': 391}