<commit_before>package notes

import (
	"strings"
	"sync"
	"time"
)

var AllNotes *Agenda

type Agenda struct {
	Notebooks map[string]string
	Notes     map[string][]Note
	rMutex    sync.RWMutex
	lastSync  time.Time
}

func init() {
	AllNotes = NewAgenda()
}

func NewAgenda() *Agenda {
	a := new(Agenda)
	a.Notes = make(map[string][]Note)
	a.Notebooks = make(map[string]string)
	return a
}

func (a *Agenda) GetNote(id int64) *Note {
	a.rMutex.Lock()
	defer a.rMutex.Unlock()

	for _, notes := range a.Notes {
		for i := range notes {
			if notes[i].Id == id {
				return &notes[i]
			}
		}
	}
	return nil
}

func (a *Agenda) AddNotebook(name string, content string) error {
	a.rMutex.RLock()
	defer a.rMutex.RUnlock()

	notes := Parse(content)
	a.Notes[name] = make([]Note, 0, len(notes))
	for i := range notes {
		notes[i].Source = name
		a.Notes[name] = append(a.Notes[name], notes[i])
	}

	a.Notebooks[name] = content
	a.lastSync = time.Now()

	return nil
}

func (a *Agenda) AddNote(n Note) {
	a.rMutex.RLock()
	defer a.rMutex.RUnlock()<commit_msg>notebooks views now show html<commit_after>package notes

import (
	"strings"
	"sync"
	"time"
)

var AllNotes *Agenda

type Agenda struct {
	Notebooks map[string]string
	Notes     map[string][]Note
	rMutex    sync.RWMutex
	lastSync  time.Time
}

func init() {
	AllNotes = NewAgenda()
}

func NewAgenda() *Agenda {
	a := new(Agenda)
	a.Notes = make(map[string][]Note)
	a.Notebooks = make(map[string]string)
	return a
}

func (a *Agenda) GetNote(id int64) *Note {
	a.rMutex.Lock()
	defer a.rMutex.Unlock()

	for _, notes := range a.Notes {
		for i := range notes {
			if notes[i].Id == id {
				return &notes[i]
			}
		}
	}
	return nil
}

func (a *Agenda) AddNotebook(name string, content string) error {
	a.rMutex.RLock()
	defer a.rMutex.RUnlock()

	notes := Parse(content)
	a.Notes[name] = make([]Note, 0, len(notes))
	for i := range notes {
		notes[i].Source = name
		a.Notes[name] = append(a.Notes[name], notes[i])
	}

	//a.Notebooks[name] = content
	a.Notebooks[name] = Org2HTML([]byte(content), "")
	a.lastSync = time.Now()

	return nil
}

func (a *Agenda) AddNote(n Note) {
	a.rMutex.RLock()
	defer a.rMutex.RUnlock()
{'fraction_non_alphanumeric': 0.1567816091954023, 'fraction_numerical': 0.003218390804597701, 'mean_word_length': 3.699784017278618, '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': '5485370', 'n_tokens_mistral': 931, 'n_tokens_neox': 891, 'n_words': 203}