<commit_before>require "bundler"
Bundler.require
require 'yaml'
include Sprockets::Helpers

require_relative "lib/git"

REPO_PATH = "git-backend"

class App < Sinatra::Base
  set :sprockets, Sprockets::Environment.new(root)

  repo = Git::Repo.new(REPO_PATH)

  get '/' do
    @items = repo.all
    redirect '/new' if @items.empty?
    haml :index
  end

  get '/done/:id' do
    repo.mark_as_done params[:id]
    redirect '/'
  end

  get '/delete/:id' do
    repo.delete params[:id], "remove a todo"
    redirect '/'
  end

  get '/new' do
    @title = "Add todo list"
    haml :new
  end

  post '/new' do
    item = {"id" => SecureRandom.uuid, "content" => params[:content], "done" => false, "time" => Time.now}
    repo.write(item.to_yaml, item["id"], "add a todo")
    redirect '/'
  end
end<commit_msg>use items/* to store todos<commit_after>require "bundler"
Bundler.require
require 'yaml'
include Sprockets::Helpers

require_relative "lib/git"

REPO_PATH = "git-backend"

class App < Sinatra::Base
  set :sprockets, Sprockets::Environment.new(root)

  repo = Git::Repo.new(REPO_PATH)

  get '/' do
    @items = repo.all
    redirect '/new' if @items.empty?
    haml :index
  end

  get '/done/:id' do
    repo.mark_as_done "items/#{params[:id]}"
    redirect '/'
  end

  get '/delete/:id' do
    repo.delete "items/#{params[:id]}", "remove a todo"
    redirect '/'
  end

  get '/new' do
    @title = "Add todo list"
    haml :new
  end

  post '/new' do
    item = {"id" => SecureRandom.uuid, "content" => params[:content], "done" => false, "time" => Time.now}
    repo.write(item.to_yaml, "items/#{item["id"]}", "add a todo")
    redirect '/'
  end
end
{'fraction_non_alphanumeric': 0.16346153846153846, 'fraction_numerical': 0.0, 'mean_word_length': 3.172932330827068, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '1800480', 'n_tokens_mistral': 621, 'n_tokens_neox': 614, 'n_words': 157}